A Tango Fibers question and a functional programming anecdote.
downs
default_357-line at yahoo.de
Sun Oct 28 20:03:00 PDT 2007
Daniel Keep wrote:
>
> BCS wrote:
>> Reply to Benjamin,
>> ...
>>> how the heck is that parsing?? Is the /map/ actualy this:
>>>
>>> (A / B) / C; ??
>>>
>> BTW if that is what you are doing, I may be force to do something
>> totally EVIL to reclaim some ground in the "does nasty things with D"
>> ranking. I have a few ideas though.... }:-) (BBBBWWWWAAAA HAA Haa
>> haaa.....)
Looking forward to it! :)
The world needs more weird and disturbing things. Shake it up.
>
> IIRC, map is basically defined like this:
>
> struct map
> {
> static map_ opDiv_r(T)(some_array_type!(T));
> }
>
> struct map_
> {
> some_array_type!(T) opDiv(T)(some_delegate_type!(T));
> }
>
> Or something similar.
>
> -- Daniel
Yes exactly; though I have all the ugliness packed around in a template.
Quote from the respective file:
>
> mixin(Operator!("map", "
> static if (is(ReturnType!(RHS)==void)) {
> foreach (ref entry; lhs) rhs(mixin(Value!(ElemType!(LHS), RHS,
"~Quote!("entry")~")));
> } else {
> auto res=new ReturnType!(RHS)[lhs.length];
> foreach (id, ref entry; res)
entry=rhs(mixin(Value!(ElemType!(LHS), RHS, "~Quote!("lhs[id]")~")));
> return res;
> }
> "));
>
More information about the Digitalmars-d
mailing list