Proposed D2 Feature: => for anonymous delegates

Jason House jason.james.house at gmail.com
Sun Oct 18 20:17:16 PDT 2009


Andrei Alexandrescu Wrote:

> Jason House wrote:
> > Am I the only one that has trouble remembering how to write an inline
> > anonymous delegate when calling a function? At a minimum, both Scala
> > and C# use (args) => { body; } syntax. Can we please sneak it into
> > D2?
> 
> We have (args) { body; }
> 
> Andrei

Somehow, I missed that. What kind of type inference, if any, is allowed? Scala and C# allow omiting the type. Lately I'm doing a lot of (x) => { return x.foo(7); } in C# and it's nice to omit the amazingly long type for x. The IDE even knows the type of x for intellisense... I think scala would allow x => foo(7), or maybe even => _.foo(7) or even _.foo(7). I haven't written much scala, so I may be way off...



More information about the Digitalmars-d mailing list