<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial,helvetica,sans-serif;font-size:12pt"><div>The type says nothing about whether it's scanned for pointers or not. Remember that it's the caller supplying the array, the void[] type just says "pass any type of array in". The function should not reallocate the array (and even if it did, the scanning bits are copied from the original, not determined by the type).<br><br>In other words, the GC cares nothing about type, it only cares what bits are set in the memory block. And those bits are set on allocation, not when a cast is made or a parameter is passed.<br><br>And on hijacking type safety, there is no type safety when reading and writing a stream. Stream data comes in or goes out as untyped data, so I think using void[] is actually more accurate to what is happening.<br><br>-Steve<br></div><div style="font-family:
arial,helvetica,sans-serif; font-size: 12pt;"><br><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><font size="2" face="Tahoma"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> Denis <2korden@gmail.com><br><b><span style="font-weight: bold;">To:</span></b> Discuss the phobos library for D <phobos@puremagic.com><br><b><span style="font-weight: bold;">Sent:</span></b> Mon, May 10, 2010 8:38:44 AM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [phobos] UnbufferedFile, or, abstracting the File ranges<br></font><br>
On Mon, May 10, 2010 at 4:24 PM, Steve Schveighoffer<br><<a ymailto="mailto:schveiguy@yahoo.com" href="mailto:schveiguy@yahoo.com">schveiguy@yahoo.com</a>> wrote:<br>> I would define only 2 i/o functions:<br>><br>> size_t read(void[] b);<br>> size_t write(const(void)[] b);<br>><br>> And then the various paraphernalia around it (close, open, etc).<br>><br>> The reason to use void[] is because any array data type can be passed to it<br>> without casting (imagine you wanted to read an array of ints).<br>><br>> Reading and writing a single byte should be discouraged with unbuffered<br>> streams. This is how it is in most I/O libs. You build your unbuffered I/O<br>> to abstract the OS functions, then build your buffered I/O and fancy<br>> functionality on top of it.<br>><br>> -Steve<br>><br><br>I think it should be byte[], not void[]. First, byte[] aren't scanned<br>for pointers by GC.
Second, it hijacks type safety. I believe you need<br>an explicit cast, even if you are sure about the type of data in the<br>file (throw in an Endianness if you are still not convienced).<br>_______________________________________________<br>phobos mailing list<br><a ymailto="mailto:phobos@puremagic.com" href="mailto:phobos@puremagic.com">phobos@puremagic.com</a><br><span><a target="_blank" href="http://lists.puremagic.com/mailman/listinfo/phobos">http://lists.puremagic.com/mailman/listinfo/phobos</a></span><br></div></div>
</div><br>
</body></html>