join

Lutger Blijdestijn lutger.blijdestijn at gmail.com
Mon Jan 24 00:31:55 PST 2011


Andrei Alexandrescu wrote:

> On 1/18/11 2:55 PM, so wrote:
>>> 2. joiner uses an idiom that I've experimented with in the past: it
>>> defines a local struct and returns it. As such, joiner's type is
>>> impossible to express without auto. I find that idiom interesting for
>>> many reasons, among which the simplest is that the code is terse,
>>> compact, and doesn't pollute the namespace. I'm thinking we should do
>>> the same for Appender - it doesn't make much sense to create an
>>> Appender except by calling the appender() function.
>>
>> Didn't know there was a solution to namespace pollution.
>> This one is a very nice idea, are you planning to use it in phobos in
>> general?
>> Retro, Stride... there should be many.
> 
> I plan to, albeit cautiously. Sometimes people would want e.g. to store
> a member of that type in a class. They still can by saying
> typeof(joiner(...)) but we don't want to make it awkward for them.
> 
> Andrei

I do this sometimes with Appender for splitting complex construction of a 
string between functions. Is that bad practice? What is the alternative 
idiom? If possible, please reconsider making Appender an existential type.


More information about the Digitalmars-d mailing list