String lambdas

QAston via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 27 08:53:25 PDT 2016


On Tuesday, 26 April 2016 at 17:58:22 UTC, Andrei Alexandrescu 
wrote:
> One thing we really need in order to 100% replace string 
> lambdas with lambdas is function equivalence. Right now we're 
> in the odd situation that SomeTemplate!((a, b) => a < b) has 
> distinct types, one per instantiation.

Well, SomeTemplate!((a, b) => a < b) uses pass by name, so it's 
sort of expected to be a distinct type for each different object 
you pass to it. Do you want to bind different lambdas (matching 
by some notion of equality) to the same symbol? That'd be an 
enormous hack.

Now, if this was:
SomeTemplate(FunctorType) // type parameter, not alias here
{
this(FunctorType f){
...
}
...
}

and (a, b)=> a < b returned an object of the same type for 
equivalent functions you could have fn equality without giving 
different objects the same symbol. It's also inlineable as pass 
by name is.


More information about the Digitalmars-d mailing list