On Monday, 4 April 2016 at 21:32:10 UTC, stunaep wrote:

Can you please explain what the scope keyword does and if there

scope was originally intended to be used primarily with classes in order to get deterministic destruction. It ensures the destructor of a class is called when the scope exits, just as with a struct. It's not needed here and shouldn't really be used at all anymore. It has been superseded by std.typecons.scoped [1]. It's not needed here at all, though. bz_stream is a struct, so there's no need to allocate an instance of it:

bz_stream stream;

Then you can just take its address when passing it to functions:

int init_error = BZ2_bzDecompressInit(&stream, 0, 0);

is any benefit to using
"new byte[](size)" over "new byte[size]" with a 1D array?

This is the newer and recommended syntax for allocating arrays. The idea is that it helps improve readability because the old syntax, "new byte[size]", brings to mind static array declarations, and that it's consistent with the syntax for allocating other types:

new T(arg);

[1] https://dlang.org/phobos/std_typecons.html#.scoped

Reply via email to