views:

128

answers:

2

Just curious how is the .NET 4.0 CLR world going to call methods ending in question marks and exclamations? What will the syntax look like calling from C# or VB.NET?

+3  A: 

I think you have to differentiate the cases a bit here.

At a CLR level there is simply no problem. The CLR allows a much larger set of characters to be included in type and member names than is typically available to most languages (such as C# and VB.Net). For instance it's legal at a CLR level to include apostrophes.

In fact if you look at section 8.5.1 of the ECMA CLI spec it doesn't explicitly restrict the character set. It merely denotes how they should be compared.

The other issue to consider is how the names are actually written to IL. There is nothing stopping IronRuby from simply excluding the exclamation points when writing out an assembly and adding them back in when reading one from disk. This type of mapping is done by other languages to turn ugly names into valid ones. For instance if you look at List<T> at an IL level, it actually is written out as List`1.

I'm not saying that IronRuby does these mappings, merely that it's possible they do. I'm actually quite unfamiliar with Ruby as a language.

As for how they are consumed from VB.Net and C#. Luckily both languages have the option defer to the DLR for interacting with raw IronPython and IronRuby. This allows the language writers flexibility in how they expose their members to other languages and allows another layer where they can map member names into their internal representation.

JaredPar
+1  A: 

From C# or VB.NET, you'll have to use the DLR hosting interfaces to access those methods, using the method name as a string. The new "dynamic" syntax from those languages does not override their normal lexical rules for valid method identifiers.

Curt Hagenlocher