On Sun, 26 Sep 2010 00:32:41 -0400, Jonathan M Davis <[email protected]>
wrote:
On Saturday 25 September 2010 19:46:37 Robert Jacques wrote:
On Sat, 25 Sep 2010 17:17:58 -0400, Andrei Alexandrescu
<[email protected]> wrote:
> This has come up in
http://d.puremagic.com/issues/show_bug.cgi?id=1482.
> Should std.file.read() return void[] or ubyte[]? There's one matter
with
> assuming that void[] may contain pointers (which is not the case for
> something read from a file), so possibly ubyte[] is a more accurate
type
> for describng raw bytes.
>
> What are the pros and cons of returning void[] vs. ubyte[]?
>
>
> Andrei
Pro:
Well, the very first thing I always do with std.file.read is to cast the
data to the type I'm working with. So:
auto data = cast(float[])read("my_data.raw");
vs.
auto data = cast(float[])(cast(void[])read("my_data.raw"));
Having read return ubyte would mean adding an extra cast in several use
cases
Why would you need two casts? I would expect that one would suffice
without the
need to cast to void[] in between.
- Jonathan M Davis
Sorry, you're right. Though I'm surprised at this behavior, since doing a
similar reinterpretation cast between incompatible classes require going
through void* first.
_______________________________________________
phobos mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/phobos