Fixed-size arrays on the heap

Pelle pelle.mansson at gmail.com
Thu May 6 04:21:28 PDT 2010


On 05/06/2010 01:10 PM, bearophile wrote:
> Lars T. Kyllingstad:
>> In particular, note Kasumi Hanazuki's post and Andrei's response to it.
>
> Thank you, it seems Andrei agrees with me. But I think here thinks have to be kept tidy, otherwise it's easy to make a mess.
>
> The syntax offers various interesting possibilities for a future International Obfuscated D Code Contest:
>
> import std.stdio: writeln;
> struct Arr(int N) {
>      int[N] data;
>      alias data this;
> }
> void main() {
>      auto p = new Arr!(10);
>      *p = 10;
>      writeln(p.data); // Output: 10 10 10 10 10 10 10 10 10 10
> }
>
>
> This is not good :-(
> Bye,
> bearophile

Which is why they decided that the [] will always be needed for array 
operations. Right?


More information about the Digitalmars-d-learn mailing list