Steven Schveighoffer, el 23 de diciembre a las 08:44 me escribiste: > grauzone Wrote: > > > Steven Schveighoffer wrote: > > > All, > > > > > > I created a new patched druntime that prevents array stomping and at the > > > same time increases append performance for thread-local array appending. > > > > > > The patch is attached to bugzilla entry 3637. ( > > > http://d.puremagic.com/issues/show_bug.cgi?id=3637 ) > > > > Nobody cares about it? (Except someone commenting in bugzilla, but > > where's Andrei and Walter?) > > I have already discussed this patch with Andrei and Walter (and the rest of > the compiler/phobos crew), they are on board. I am a little disappointed > with the response here, but I guess it could be attributed to the barrier to > experimentation (you have to apply the patch and compile the runtime) and the > likelihood that many are on vacation right now (as I will be as of tonight). > > > Also, what again were the arguments against adding a "capacity" field in > > the slice struct to deal with the append problem? > > The problem is that adding a capacity field only works if the object is > a reference type. A value type will make either choose to make copies > of the capacity field, resulting in the same stomping problem (and maybe > worse), or will zero out one of the copy's capacity field, resulting in > an artificial limitation for appending. The only true way to make this > work right is to have a capacity field shared among all the aliases to > the same data, and the most logical place for that is in the allocated > block.
This is making the half-value, half-reference semantics of arrays even worse, since now the capacity is "passed by reference" (at the end of the array data) but the length and ptr as values. I don't comment much about the patch (and the design) because I already did so in the several threads about it. I think is a very bad idea, I think dynamic arrays should be a proper reference type (with ptr, length and capacity) and slices should be a value type without appending (only with ptr and length). -- Leandro Lucarella (AKA luca) http://llucax.com.ar/ ---------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------- You can do better than me. You could throw a dart out the window and hit someone better than me. I'm no good! -- George Constanza
