RFC on range design for D2

bearophile bearophileHUGS at lycos.com
Thu Sep 11 10:22:27 PDT 2008


Oskar Linde (and Andrei Alexandrescu):
> So by removing ~= from T[], T[] becomes a pure slice type.

Appending to the built-in dynamic arrays is a fundamental operation (I use it hundred of times in my code) so if the purpose is just to avoid problems when extending slices, a different solution can be invented.
For example adding the third (capacity) field to the dyn array struct, the last bit of the capacity field can be used to tell apart slices from true whole arrays. So at runtime the code knows how to extend/append the array/slice correctly. This slows down the appending itself a little, but it's better than having to use an ugly ArrayBuilder everywhere.

Bye,
bearophile


More information about the Digitalmars-d-announce mailing list