My thoughts & experiences with D so far, as a novice D coder
Vidar Wahlberg
vidar.wahlberg at gmail.com
Thu Mar 28 16:38:25 PDT 2013
On Thursday, 28 March 2013 at 22:22:49 UTC, Chris Cain wrote:
> Sorry about the repeated postings ... I'm trying to read &
> answer it while also dealing with the norovirus :x
Been there. Not amusing, I wish you well.
>> "why is this done like this, couldn't it be done much easier?".
>
> Maybe. What needs to be made easier and how would you suggest
> to fix it? The error message, certainly. Probably the
> documentation too. But the API itself seems sane to me in this
> instance, it just needs a better description.
Well, I'm not so proficient in the language yet that I'm going to
climb to the top of Mount Stupid and say how it should be,
because for what I know this may be perfectly logical with just
me being blind to it, but to try to explain how it would make
more sense to me:
Since you got "ubyte[] buffer = [0, 0, 0, 0];
buffer.write!int(42); buffer.read!int();", I think it would be
logical that "ubyte[] buffer; buffer.append!int(42);
buffer.read!int()" would do pretty much the same (except instead
of writing 4 bytes at index 0, it appends 4 bytes to the end of
the array, then reads back the value). The latter code does
however give you "Attempting to fetch the front of an empty array
of ubyte".
I don't get why you need to drag in std.array.appender() for
std.bitmanip.append(), when you don't need it for read() and
write().
More information about the Digitalmars-d
mailing list