D array expansion and non-deterministic re-allocation
Leandro Lucarella
llucax at gmail.com
Wed Nov 18 15:43:29 PST 2009
Andrei Alexandrescu, el 18 de noviembre a las 07:22 me escribiste:
> Leandro Lucarella wrote:
> >Andrei Alexandrescu, el 17 de noviembre a las 18:45 me escribiste:
> >>>3. If you **really** care about performance, you should only append when you
> >>>don't know the length in advance. If you know the length, you should always
> >>>pre-allocate.
> >>We will have collections and all those good things, but I don't see
> >>how the proposal follows from the feedback. My perception is that
> >>this is a group of people who use D. Bartosz' concern didn't cause
> >>quite a riot, so as far as I can tell there is no big issue at
> >>stake.
> >
> >I didn't say anything (until now) because this was discussed already.
> >Dynamic arrays/slices appending is horribly broken (I know it's well
> >defined, and deterministic, but you are just condemned to make mistakes,
> >it just doesn't work as one would expect, even when you know how it works
> >you have to keep fighting your intuition all the time).
>
> In which ways do you think arrays horribly broken? Same as Bartosz mentions?
Yes, I think dynamic arrays are grouping 2 separate things: a proper
dynamic array able to efficiently appending stuff (without hacks like the
size cache) and a slice (a read-only view of a piece of memory); a "random
range" if you want to put it in terms of D.
A dynamic array should be a reference type, a slice a value type.
I explained my view before. I wont explain it with much detail again (I
hope you remember the thread).
> One question is whether you actually have had bugs and problems
> coding, or if arrays stopped you from getting work done.
I had many bugs because of the reallocation when appending.
> >But it's a little pointless to keep making riots, when we were so close
> >to finally fix this with T[new]/whatever and it all went back.
>
> Hmmmm... resignation is not a trait of this group :o).
It is after a good fight :)
>From time to time this kind of issues (that are present in the group since
I can remember, which is about 4 years maybe) keep popping in the NG. I
get tired of repeating myself over and over again (like may others,
I guess).
--
Leandro Lucarella (AKA luca) http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
Hey, it's George. I got nothing to say.
-- George Constanza, dejando un mensaje en la contestadora de Jerry
More information about the Digitalmars-d
mailing list