new std.variant (was Re: The Right Approach to Exceptions)

Juan Manuel Cabo juanmanuel.cabo at gmail.com
Wed Feb 22 18:12:18 PST 2012


On Thursday, 23 February 2012 at 01:57:49 UTC, Jonathan M Davis 
wrote:
> The D equivalent would really be Array, not Appender.

Array!T in D is ref counted and more geared towards T being a
struct. And I had big trouble sorting it with sort!()() in D2.056,
so I made my own sort just to be able to use Array!(T).

I know that that situation will not remain forever (and I didn't
check if it was already fixed in D2.058).

> I'm not sure that it's a great idea to use Appender as a
> container - particularly when there are types
> specifically intended to be used as containers. Appender is 
> geared specifically  towards array building (like StringBuilder 
> in Java, except generalized for all
> arrays). If it's a container that you're looking for, then I 
> really think that
> you should use a container.
>
> - Jonathan M Davis

If Appender supports the range interface, then it is a
container. Someone will use it that way, because in the real
world people take the things for what they are, not for
what they are named.

Appender can work with T classes well. Contains items.
It would be GC managed (as opposed to Array!T).
So it is a container. If it is not O(1) to access, it
should be said big in the ddoc though.

It is a recurrent trend in your posts, that you post just
because you have some ideallistic concern or opinion.

If we are going to get ideallistic, this is an extract
of a poem by Jorge Luis Borges (argentinian writer) that
illustrates my point:

       If (as the Greek states in the Cratilo)
       the name is the archetype of the thing,
       in the letters of rose it is the rose
       and all the Nile is in the word Nile

       Si como escribió el griego en el Crátilo,
       el nombre es arquetipo de la cosa,
       en el nombre de rosa está la rosa
       y todo el Nilo en la palabra Nilo.
       --Jorge Luis Borges

--jm













More information about the Digitalmars-d mailing list