On 6 February 2015 at 23:42, David Nadlinger via Digitalmars-d <digitalmars-d@puremagic.com> wrote: > On Friday, 6 February 2015 at 23:37:30 UTC, Iain Buclaw wrote: >> >> Simple, you implement it by allocating no memory. :) > > > Let me put it a different way. Imagine you have this in your program: > > --- > void foo() { > int[0] a0; > int[0] a1; > ... > int[0] a99; > > // Do something with them. > } > --- > > How do you choose the addresses for a0 through a99 so that they are > distinct, but you don't end up allocating 100 bytes of stack memory? > > David
There are no addresses for them, you can't do *anything* with them at runtime. Some cod scenarios: 1. Comparisons of == fold into 'false' (unless comparing to self) 2. Comparisons of != fold into 'true' (unless comparing to self) 3. Conversion to dynamic arrays is { .length=0, .ptr=&arr0 } You cannot assign memory/address to them directly, but you can assign it indirectly. This 'indirect assignment' can only really work if it were the last member of a struct. Example usage - http://goo.gl/uAbxKN - something like a pointer-based dynamic array. Labels probably do best describe their exact behaviour. Iain.