Anonymous function syntax

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Sep 22 14:01:07 PDT 2011


On 9/22/11 3:54 PM, Andrei Alexandrescu wrote:
> On 9/21/11 5:17 PM, Walter Bright wrote:
>> I've collected a few from various languages for comparison:
> [snip]
>
> I think we should do the following:
[snip]

I can't believe I forgot an all-important aspect.

A function literal should be comparable to another for equality. Two 
function literals are equal if they have the same token type sequence 
(up to alpha renaming) and use the same environment.

Example:

bool test(auto fun)()
{
     return fun == (x, y => x + y);
}

unittest
{
     assert(test!(a, b => a + b)());
}

This will not be easy to implement (especially when environment 
dependencies come into play) but is necessary.


Andrei


More information about the Digitalmars-d mailing list