On Tuesday, 27 May 2014 at 15:40:04 UTC, Luís Marques wrote:
On Tuesday, 27 May 2014 at 15:06:53 UTC, bearophile wrote:
BTW, why doesn't this example work with lambdas (a => a != 2)
instead of a string mixin ("a != 2")?
I think lambda instantiations defines a different type. So
it's incompatible.
Incompatible with what? I meant changing it in both the
declaration and the initialization.
Lambdas are not "cached", so each lambda is unique even if it's
code is the same:
void main(){
pragma(msg,(int a)=>a); //prints __lambda1
pragma(msg,(int a)=>a); //prints __lambda2
}
At any rate, you can't use lambdas(neither `delegate` nor
`function`) when declaring a member of class or struct, since D
will treat it as a method(rather than a static function) and
complain about the `this` reference.