While we were discussing lambda syntax..

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Jan 1 10:51:23 PST 2011


On 1/1/11 11:37 AM, Philippe Sigaud wrote:
>>> I just developed a n-args
>>> version of UnaryFun/BinaryFun, which was one of the most useful little
>>> helper I ever did in D.
>>
>> Great! I recall I tried to do that a couple of years ago, but hit a few
>> bugs. Could you make NaryFun into a proposal for Phobos?
>
> Sure. It uses a simple heuristics to automatically determine the
> 'string arity': it looks for lone letters (not surrounded by other
> letters). In practice it works quite well and there is a optional
> arity, if you need one.
>
> The current code still uses templates instead of CTFE for this arity
> determination. I'll change that and propose it.
>
> One of my week-end plan was to do a curried version. That is
> curriedFun!"a+b*c" would create not a 3-arg function template but
> three unary templated funs inside one another. I find currying most
> useful for mapping and filtering ranges...
>
> Would that be of interest for someone?
>
> Philippe

You'd need to prove usefulness, which I suspect shouldn't be all too 
difficult in this case.

Andrei


More information about the Digitalmars-d mailing list