On Sun, 31 May 2009 22:41:47 +0300, Walter Bright <[email protected]> wrote:
> Vladimir Panteleev wrote: >> I don't know why it was decided to mark the contents of void[] as >> "might have pointers". It makes no sense! Consider: > > [...] > >> 3) It's very rare in practice that the only pointer to your >> object (which you still plan to access later) to be stored in a >> void[]-allocated array! > > Rare or common, it still would be a nasty bug lurking to catch someone. > The default behavior in D should be to be correct code. Doing > potentially unsafe things to improve performance should require extra > effort - in this case it would be either using the gc function to mark > the memory as not containing pointers, or storing them as ubyte[] > instead. This isn't about performance, this is about having one thousand casts all over my code. It becomes a burden to cast everything to ubyte[] when working with abstract binary data. For example, when building a MIME multipart message with binary fields, every line needs to have a cast in it - when we could have just used the ~= operator to append to a void[]. Alternative solutions would be to have a second type (either new or one of the existing, e.g. ubyte[]) act as void[] (any array type casts to it implicitly) but not be scanned by the GC, but I doubt this is something you'll consider -- Best regards, Vladimir mailto:[email protected]
