0

I've been learning a lot about IL recently with my new job. I have a question though that I can't quite find an answer for.

All of the documentation I've seen indicates that anonymous methods(for use in delegates) isn't supported on .Net 1.1. However, in the IL, anonymous methods appears to be implemented by just using regular methods with "impossible" names.

So what about anonymous methods makes them unsupported on .Net 1.1? Is there something I'm missing?

Earlz
  • 62,085
  • 98
  • 303
  • 499
  • Could you point to the documentation you're talking about? – svick Aug 11 '12 at 00:39
  • I know there is no such thing as a dumb question, but this is like asking why you can't run your horse and cart on gasoline, because your more modern transport does. – dano Aug 11 '12 at 01:16
  • @svick http://msdn.microsoft.com/en-us/magazine/cc163682.aspx#S5 or just go to google and type in `anonymous methods .net 2.0`.... and the C# compiler won't let you create anonymous methods when targetting .Net 1.1. – Earlz Aug 11 '12 at 01:22
  • @Evildonald No, it's more like if there was a new type of gasoline to come out that for some reason arbitrarily was documented won't work in old cars, yet it's exactly the same. – Earlz Aug 11 '12 at 01:23
  • @Earlz That doesn't talk about .Net 2.0, it talks about C# 2.0. And it's certainly true that anonymous methods were new in C# 2.0. Versions of .Net and C# are closely related, but still different. – svick Aug 11 '12 at 01:58

2 Answers2

4

So what about anonymous methods makes them unsupported on .Net 1.1? Is there something I'm missing?

The compilers that target .Net 1.1 did not support this, so there was no way to create one in the 1.1 version of the Framework.

A custom language or compiler could, of course, make a version of anonymous methods - but nothing did at the time.

Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373
  • Ah... that's what I was thinking, but it didn't make any sense to me as to why they wouldn't go backwards and add support to .Net 1.1 targets for such a thing – Earlz Aug 11 '12 at 00:24
  • 1
    @Earlz .NET 2 was such a huge change (with generics, etc) that I don't think there was much desire to go do anything with 1.1 after it came out... – Reed Copsey Aug 11 '12 at 00:25
  • It seems then like anonymous methods isn't anything new to .Net 2.0, but rather new to the C# compiler(whatever version tied to .Net 2.0).. They've went backwards plenty before. You can compile things using the C# 4.0 compiler, that targets .Net 2.0. Of course, only language features are supported, and not framework features... My question is why anonymous methods are classified as a framework feature, but really a language feature – Earlz Aug 11 '12 at 01:27
  • 1
    @Earlz They're not a framework feature - they're a language feature. The documentation you're quoting is just not clear on it. – Reed Copsey Aug 11 '12 at 18:56
2

I think the documentation is misleading. What it should state is that anonymous methods are not supported in early versions of the managed languages (VB, C#, C++/CLI).

As you have discovered, there is no notion of an anonymous method in IL; it is up to the language to make them anonymous (by hiding them with mangled names).

Steve Guidi
  • 19,700
  • 9
  • 74
  • 90