December 08, 2007 Re: Reading a file eats whole memory | ||||
---|---|---|---|---|
| ||||
Jarrett Billingsley:
> import std.file;
> int main(char[][] args)
> {
> ubyte[] data = cast(ubyte[])std.file.read(args[0]);
> return 0;
> }
>
> Two things: one, std.file.read returns a void[], which is a bit like D's equivalent of a void*
I don't understand the design of that std.file.read(): why don't return a ubyte[] by default instead of a void[] (and cast it to everything else if you don't need ubytes)?
Bye,
bearophile
|
December 09, 2007 Re: Reading a file eats whole memory | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | bearophile Wrote:
> Jarrett Billingsley:
> > import std.file;
> > int main(char[][] args)
> > {
> > ubyte[] data = cast(ubyte[])std.file.read(args[0]);
> > return 0;
> > }
> >
> > Two things: one, std.file.read returns a void[], which is a bit like D's equivalent of a void*
>
> I don't understand the design of that std.file.read(): why don't return a ubyte[] by default instead of a void[] (and cast it to everything else if you don't need ubytes)?
>
> Bye,
> bearophile
1) It doesn't matter. You're supposed to cast it anyways based on the type of data in the file.
|
Copyright © 1999-2021 by the D Language Foundation