Why are void[] contents marked as having pointers?
Vladimir Panteleev
thecybershadow at gmail.com
Mon Jun 1 00:03:48 PDT 2009
On Sun, 31 May 2009 23:24:09 +0300, Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org> wrote:
> Another alternative would be to allow implicitly casting arrays of any
> type to const(ubyte)[] which is always safe. But I think this is too
> much ado about nothing - you're avoiding the type system to start with,
> so use ubyte, insert a cast, and call it a day. If you have too many
> casts, the problem is most likely elsewhere so that argument I'm not
> buying.
I've thought about this for a bit. If we allow any *non-reference* type except void[] to implicitly cast to ubyte[], but still allow implicitly casting ubyte[] to void[], it will put ubyte[] in the perfect spot in the type hierarchy - it'll allow safely (portability issues notwithstanding) getting the representation of value-type (POD) arrays, while still allowing abstracting it even further to the "might have pointers" type - at which point it is unsafe to access individual bytes, which void[] disallows without casts.
--
Best regards,
Vladimir mailto:thecybershadow at gmail.com
More information about the Digitalmars-d
mailing list