Future of string lambda functions/string predicate functions

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Aug 11 09:26:17 PDT 2013


On 8/8/13 9:52 AM, Jonathan M Davis wrote:
> On Thursday, August 08, 2013 07:29:56 H. S. Teoh wrote:
>> Seems this thread has quietened down. So, what is the conclusion? Seems
>> like almost everyone concedes that silent deprecation is the way to go.
>> We still support string lambdas in the background, but in public docs we
>> promote the use of the new lambda syntax. Would that be a fair
>> assessment of this discussion?
>
> I find it interesting that very few Phobos devs have weighed in on the matter,
> but unfortunately, most of the posters who have weighed in do seem to be
> against keeping them.

There's a related issue that I think we must solve before deciding 
whether or not we should deprecate string lambdas. Consider:

void main() {
     import std.range;
     SortedRange!(int[], "a > b") a;
     SortedRange!(int[], "a > b") b;
     b = a;
     SortedRange!(int[], (a, b) => a > b) c;
     SortedRange!(int[], (a, b) => a > b) d;
     d = c;
}

The last line fails to compile because D does not currently have a good 
notion of comparing lambdas for equality. In contrast, string comparison 
is well defined, and although string lambdas have clowny issues with 
e.g. "a>b" being different from "a > b", people have a good 
understanding of what to do to get code working.

So I think we should come up with a good definition of what comparing 
two function aliases means.


Andrei



More information about the Digitalmars-d mailing list