Title

Comments

  1. Would be nice if we could choose to capture value or variable, as can be done in C++

    ReplyDelete
  2. David Heffernan Yes, that would be nice, but I think there is no hope......

    ReplyDelete
  3. I've been bitten by this too, and I also used parameterized factory functions. In general, I try to avoid using local variables declared outside the anon methods, and only deal with arguments, but of course, that is almost impossible to completely avoid.

    ReplyDelete
  4. Lars Fosdal Without capture, there's pretty much no point to anonymous methods. If you don't have capture, then what do anonymous methods add over the pre-existing procedural types?

    ReplyDelete
  5. David Heffernan I f.x. use them to inject comparators, conditional formatters, decorators, stylers and event handlers.

    ReplyDelete
  6. Lars Fosdal But we could do all of that perfectly well without anonymous methods using other procedural types.

    I guess the point you are making is that you can define them inline as opposed to having to declare a function elsewhere, give it a name, and so on.

    ReplyDelete
  7. David Heffernan True that. Inline declaration is convenient - and it can be combined with assignment of regular declared methods.

    ReplyDelete
  8. And imagine how much nicer it would be if we had lambda syntax

    ReplyDelete
  9. David Heffernan That would indeed be nice in some settings.

    ReplyDelete

Post a Comment