String lambdas
poliklosio via Digitalmars-d
digitalmars-d at puremagic.com
Sun May 1 09:48:27 PDT 2016
On Tuesday, 26 April 2016 at 17:58:22 UTC, Andrei Alexandrescu
wrote:
> https://github.com/dlang/phobos/pull/3882
>
> I just closed with some regret a nice piece of engineering.
> Please comment if you think string lambdas have a lot of
> unexploited potential.
>
> 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.
>
>
> Andrei
I will just point out an obvious solution to the problem of
having distinct types: if a normal lambda is sufficiently simple,
and is used as a template parameter, lower the code to the one
which uses an equivalent string lambda.
The string needs to somewhat normalized so that (a, b) => a < b
and (c,d) => c<d are converted to the same string.
Whether the compiler allows explicit string lambdas in user code
in another issue.
More information about the Digitalmars-d
mailing list