On Thu, 14 Oct 2010 09:33:54 -0400, Denis Koroskin <2kor...@gmail.com>
wrote:
On Thu, 14 Oct 2010 17:24:34 +0400, Steven Schveighoffer
<schvei...@yahoo.com> wrote:
On Wed, 13 Oct 2010 18:21:16 -0400, bearophile
<bearophileh...@lycos.com> wrote:
Andrei:
Well casting from void[] is equally awkward isn't it? I'm still
undecided on which is better.
See also:
http://d.puremagic.com/issues/show_bug.cgi?id=4572
Bye,
bearophile
That issue is slightly different because std.file.read actually creates
the buffer. In this cases, the buffer is not created, dup'd,
concatenated, etc. so void[] offers the most flexibility.
-Steve
That is also the least safe:
Object[] objects;
stream.read(objects); // most likely will fill with garbage
writeln(objects[0]); // access violation
It's a type subversion that doesn't require casts.
Yes, and this is a problem.
But on the flip side, requring casts for non-ubyte value types may be too
restrictive. Do we want to require casts when the array being filled is
for example utf-8? If so, then won't that disallow such a function in
safe D?
I'm unsure which is worse. To be sure, allowing references to be blindly
filled in is not a good thing. But disallowing reading a file properly in
safe D is not good either.
Are there other techniques we can use? I like the use of void[] because
it says what it is -- I don't have any knowledge of your typeinfo, I'm
just going to fill in whatever you tell me to.
What we need is a type that is implicitly castable from pure value types
-- a non-pointer-void. Does this make sense? Is it too much?
-Steve