[Issue 4572] std.file.read return type

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Aug 3 07:15:38 PDT 2010


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


nfxjfg at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nfxjfg at gmail.com


--- Comment #2 from nfxjfg at gmail.com 2010-08-03 07:15:34 PDT ---
I say using the void[] type is a design error in this case. void[] is just a
safer void*. void[] should only be used in cases when you have to reference a
specific region of memory. You use it because the type system is not expressive
enough to describe the actual type (see Variant and so on).

But in this case, it's very clear what the actual data type is: it's an array
of bytes. File contents are nothing else than untyped bag of bytes. Thus the
return type should be ubyte[].

Note that reinterpret casting ubyte[] slices to other arrays or structs is not
clean: there are issues of byte order and padding. This too doesn't apply to
void[]. There's a clear difference.

Tange makes the same error.

-- 
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