Dynamically Sized Structs
Kagamin via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Apr 17 21:26:27 PDT 2014
On Wednesday, 16 April 2014 at 23:36:05 UTC, bearophile wrote:
> Jeroen Bollen:
>
>> Is it possible to have a structure with a dynamic size?
>
> See an usage example I have written here:
> http://rosettacode.org/wiki/Sokoban#Faster_Version
This can illustrate
1. fairly straightforward translation of true C code to better C
(bound checked D); such translation is important if one doesn't
want to deeply refactor the debugged algorithm, but still
reasonably gets bound checked code.
2. how easy is it to write such bound checked code.
3. developer doesn't need to design both safe and unsafe versions
(as in C and C++, it can give better control of optimization, but
is counterproductive, when you want to turn off safety globally),
he writes safe code and gets unsafe one for free - with a
compiler switch, and sees for himself, how big is performance
trade-off - effortlessly, no work was spent on unsafe version,
which can be another advertisement for D.
More information about the Digitalmars-d-learn
mailing list