[Issue 4572] std.file.read return type

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Aug 4 08:20:34 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4572



--- Comment #8 from bearophile_hugs at eml.cc 2010-08-04 08:20:32 PDT ---
Steven Schveighoffer:

> Well, I would assume it would return an int[][], which probably would mean
> nothing since arrays are pointer/length values, and any pointer/length values
> read from a file would be bogus.  I'd say read should reject reading elements
> that have references in them.

Yes, you are right, I probably meant a static array, so this reads a dynamic
array of ints:
std.file.read!(int[])();
A static array of two ints:
std.file.read!(int[2])();
A static array of static array of ints (the memory of a fixed-size matrix is
contiguous in D):
std.file.read!(int[2][5])();

The problem is that such syntax doesn't read the items of the static array
in-place, the result is a static array that gets copied. So you need an
argument by ref:

int[2][5] m;
std.file.read(T)(ref T m);

I don't like this a lot.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list