March 16, 2005
Hello,

i try to understand the difference between void[],char[] and byte[] is there any documentation about that?


Ok, i think void[] has no typ. The read function in std.file use void[]

import std.stdio; int main(){

void[] buf = "house"; char[] str = "windo"; byte[] byt = cast(byte[])"floor";

writefln("buf = %s",cast(char[])buf); writefln("void Länge = %d",buf.length); writefln("void size = %d\n",buf.sizeof); //writefln("Typ von %s",typeid(typeof(buf)));  // this didn't work for void[]

writefln("str = %s",cast(char[])str); writefln("str Länge = %d",str.length); writefln("str size = %d",str.sizeof); writefln("Typ von %s\n",typeid(typeof(str)));

writefln("byt = %s",cast(char[])byt); writefln("byt Länge = %d",byt.length); writefln("byt size = %d",byt.sizeof); writefln("Typ von %s",typeid(typeof(byt)));

return 0; }

Output:

buf = house void Länge = 5 void size = 8

str = windo str Länge = 5 str size = 8 Typ von char[]

byt = floor byt Länge = 5 byt size = 8 Typ von TypeInfo_Ag    ???





March 16, 2005
nix wrote:

> i try to understand the difference between   void[],char[] and byte[]   is there any documentation about that?   

void[] has a (void*) .ptr and holds "anything",
char[] has a (char*) .ptr and holds UTF-8 code units,
byte[] has a (byte*) .ptr and holds signed bytes...

They all three have their .length given in bytes.

> writefln("buf = %s",cast(char[])buf);  writefln("void Länge = %d",buf.length);  writefln("void size = %d\n",buf.sizeof);  //writefln("Typ von %s",typeid(typeof(buf)));  // this didn't work for  void[]  

This a bug in Phobos, std/typeinfo/ti_Av.d is missing. :-(

> writefln("byt = %s",cast(char[])byt);  writefln("byt Länge = %d",byt.length);  writefln("byt size = %d",byt.sizeof);  writefln("Typ von %s",typeid(typeof(byt)));  
[...]
> Typ von TypeInfo_Ag    ???   

This is *another* Phobos bug, ti_Ag.d has no toString()...

--anders