On 06/17/2012 03:53 PM, Philippe Sigaud wrote:
On Sun, Jun 17, 2012 at 3:11 PM, Guillaume Chatelet
<[email protected]>  wrote:
On 06/17/12 14:23, Philippe Sigaud wrote:

void main(){
    auto a = constrained!(x =>  x>  0)(1);
    auto b = a;
    auto c = b+1;
    auto d = c+a;
    a = b-d; // Boom!
}

Very nice :)

The new syntax for lambdas is delightful to use. A bunch of aliases
should give you the X10 examples.

x =>  ... still has some problem as it's a template, but using a
standard module-level function gives functionalities akin to X10:

bool pos(int x) { return x>  0;}
alias Constrained!(int, pos) Positive; // works

// alias Constrained!(int, (int x) { return x>  0;}) Positive; // works
// alias Constrained!(int, (int x) =>  x>  0) Positive; // works
// but:
// alias Constrained!(int, (x) { return x>  0;}) Positive; // ka-boom!
// alias Constrained!(int, x =>  x>  0) Positive; // no such luck


I have reported this bug a few days ago:
http://d.puremagic.com/issues/show_bug.cgi?id=8242

Apparently, Kenji Hara has already fixed it.

Reply via email to