void[] and ubyte[]
Andrej Mitrovic
andrej.mitrovich at gmail.com
Mon Feb 4 16:48:32 PST 2013
On 2/5/13, Stephan <stephan_schiffels at mac.com> wrote:
> In phobos there are places with void[] and places with ubyte[]
One benefit of void[] over ubyte[] is implicit conversion. E.g.:
void input(void[] arr) { }
void main()
{
input([1, 2]);
input([1.0, 2.0]);
input(["foo", "bar"]);
}
You don't get that conversion with byte arrays.
And the benefit of byte[] over void[] is that (at least theoretically
IIRC) the garbage collector won't scan byte arrays but it will scan
void arrays. This means the GC could interpret an element in a void[]
as a pointer and end up never releasing some bit of memory.
Someone should expand on this better than me, but I think that's the gist of it.
More information about the Digitalmars-d-learn
mailing list