On 10/13/10 14:03 CDT, Steven Schveighoffer wrote:
On Mon, 11 Oct 2010 20:33:27 -0400, Andrei AlexandrescuT[] join(T)(in T[][] items, T[] sep);This doesn't quite work if T is not a value type (actually, I think it does, but only because there are bugs in the compiler).
My focus in this discussion is not the const aspect, but point taken.
Well, one could have a version of join that takes an output range. It
would have to return the output range instead of the *result* of the
output range. And in that case, the standard join which returns an array
can be implemented:
ElementType!R1[] join(R1 items, R2 sep) ...
{
return join(R1, R2, Appender!(ElementType!R1)).data;
}
Yah, I had a similar idea: void join(In1, In2, Out)(In1 items, In2 sep, Out target); as an overload.
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!"?It's not a problem with phobos, it's a problem with documentation. There is a fundamental issue with documenting complex templates which makes function signatures very difficult to understand. The doc generator can and should simplify things, and I think at some point we should address this. In other words, it should be transformed into a form that's easy to see that it's the same as string[] join(string[][], string[]).
Good point. On the other hand, an overly simplified documentation might hinder a good deal of legit uses for advanced users. I wonder how to please everyone.
Andrei
