So now that Beta 1 has been out and fairly widely availible for a while, how do you use anonymous methods?
When I was working on them I saw several contrived examples. I saw several that seemed more like abuses than legitimate uses. In my earlier posts I pointed out some of the problems the compiler has with ‘optimizing’ the code generated for anonymous methods and the methods that contain them. In many cases I simply had to brainstorm with other until we came up with a logical guess for the most likely use and a solution that worked well for that case while not overly penalizing the less common cases.
Are you a functional programmer that likes doing completions? Do you try and morph C# into something more like Scheme or Lisp? (I’ve seen code like this, but I’ve never felt comfortable writing code like this)
Are you more of a Pascal hacker that uses anonymous methods like nested methods? (I’ve done this a few times)
I haven’t found a good name for this last style, so for now I’ll call it the lazy style: where you use an anonymous method instead of real method just because it’s faster. Like when a WinForms event handler only has one line of code, it just seems silly to write a whole method for that one line. I have also seen this taken to extremes: a WinForm with all the event handlers inlined as anonymous methods into the form’s InitializeComponents method! In my mind this makes sense for small methods, but not big ones.
Lastly, how you found problems with anonymous methods that prevent your from using them where you want to? For example: the performance is too slow, too much memory overhead, etc.