Static inline field initialization
H. S. Teoh via Digitalmars-d
digitalmars-d at puremagic.com
Tue Aug 22 09:33:15 PDT 2017
On Tue, Aug 22, 2017 at 04:28:43PM +0000, Moritz Maxeiner via Digitalmars-d wrote:
[...]
> I'd argue that - as new in this case doesn't allocate on the heap, but
> in the resulting application's appropriate segments) - it should work
> like this (from a language semantics standpoint):
>
> ---
>
> class Test
> {
> shared(ubyte)[] buf = new shared(ubyte)[1000]; // classic global
> storage, instances in all threads refer to the same static array
> }
>
> class Test
> {
> ubyte[] buf = new ubyte[1000]; // thread local storage, instances in the
> same thread refer to the same static array
> }
> ---
Sounds like a good idea. Please file this in bugzilla (if it isn't
already) so that it doesn't get lost in the ether.
T
--
Two wrongs don't make a right; but three rights do make a left...
More information about the Digitalmars-d
mailing list