Hi D
I have bit of code that was tripping me up. I need to parse small fields out of a big binary read, and it looks like some operations just can't be composed when it comes to
using templates. So this works:
import std.bitmanip, std.system;
ubyte[8192] data;
ubyte[] temp = data[4..6];
ushort us = temp.read!(ushort, Endian.bigEndian);
// intentionally provided the default byte order for readability
But this doesn't work:
import std.bitmanip, std.system;
ubyte[8192] data;
ushort us = data[4..6].read!(ushort, Endian.bigEndian);
The reasons for this are probably old hat for seasoned D programmers by this is really confusing for newbies.
Is there a better way to handle this instead of making a bunch of temporary variables that I don't care about? Matlab has this behavior too, statements that should be composable aren't, and it drives me crazy since Java and Python don't seem to suffer from this problem near a much.