ch-ch-changes

Daniel Keep daniel.keep.lists at gmail.com
Wed Jan 28 16:03:06 PST 2009



Andrei Alexandrescu wrote:
> Jason House wrote:
>> I think algorithm signatures should not be made unnecessarily
>> complex, and instead rely on other utilities for complex behavior.
>> For example map!("a*a")(r1,r2) can be implemented as
>> map!("a*a")(chain(r1,r2))
> 
> Yah, good point. I'm ambivalent about that. On one hand composition is
> nice, on the other hand map is likely to be used very often so a
> shortcut is welcome. What do others think?

Actually, my first instinct looking at this is to assume that it should
be this:

map!("a*b")(r1,r2);

Every time I've used map, multiple sequences translated to multiple
arguments of the operation.

It's really a question of style, but I think in this case it might be
worth disallowing multiple arguments since it's not clear which
behaviour it has.

(That or change it to use the behaviour -I- expect, but that's just
being selfish :D )

>> I also see in the docs that the structs returned are documented,
>> complete with all the functions that they include.  I'd hope that we
>> could somehow document this stuff simpler...
>>
>> Maybe the following? outputRangeType!(r) map!(fun)(r)
>>
>> note also how accepting only one range also makes documenting the
>> return type easier ;)
> 
> I'm waiting for that "auto" return feature to work with ddoc...

Me, I prefer cheating like a bastard...

version( DDoc )
{
    /// Stuff!  Information!  Cookies!
    RangeOf!(R) map!(Predicate)(RangeOf!(R));
}
else
{
    ReallyLongHorriblyComplex!(TemplateWithNested!(R,ThingsIn!(It))) ...
}

  -- Daniel



More information about the Digitalmars-d mailing list