improving the join function

bearophile bearophileHUGS at lycos.com
Mon Oct 11 17:45:34 PDT 2010


Andrei:

> One thing is still bothering me: the array output type. Why would the 
> "default" output range be an array?

The chain() function that returns a range is already present.


> What can be done to make join() at 
> the same time a general function and also one that works for strings the 
> way the old join did?

> I also have a question from people who dislike Phobos. Was there a point 
> in the changes of signature above where you threw your hands thinking, 
> "do the darn string version already and cut all that crap!"?

Too much over-generalization is bad, and not just for D newbies. So std.string may contain wrappers specialized for strings. You may implement a generic std.algorithm.join, and then implement the std.string.join that uses just strings (the second argument may be a single char too) and calls std.algorithm.join for its implementation.

Bye,
bearophile


More information about the Digitalmars-d mailing list