Streaming library

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Oct 14 07:41:42 PDT 2010


On 10/14/10 8:33 CDT, Denis Koroskin wrote:
> On Thu, 14 Oct 2010 17:24:34 +0400, Steven Schveighoffer
> <schveiguy at yahoo.com> wrote:
>
>> On Wed, 13 Oct 2010 18:21:16 -0400, bearophile
>> <bearophileHUGS at 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.

Excellent point.

Andrei


More information about the Digitalmars-d mailing list