Proposal to add 'Elements of Programming' Concepts to std.traits

Timon Gehr timon.gehr at gmx.ch
Sun Jun 17 09:39:50 PDT 2012


On 06/17/2012 03:53 PM, Philippe Sigaud wrote:
> On Sun, Jun 17, 2012 at 3:11 PM, Guillaume Chatelet
> <chatelet.guillaume at gmail.com>  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.


More information about the Digitalmars-d mailing list