A Refcounted Array Type

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Tue Mar 3 05:53:03 PST 2015


On 3/2/15 10:38 PM, ketmar wrote:
> On Mon, 02 Mar 2015 15:43:42 -0500, Steven Schveighoffer wrote:
>
>> I think in this case, the compiler can probably statically reject the
>> code.
>
> it can't, 'cause it doesn't know how the given object is going to be
> allocated. i may completely skip GC and use my own allocator, which has
> no troubles with threads, for example.
>

Classes are expected to be GC allocated. But the point is moot, because 
statically rejecting this does not guarantee abuse will not happen. And 
I don't think this restriction should be enshrined in the language 
anyway -- it's quite possible to write a GC that behaves correctly here.

-Steve


More information about the Digitalmars-d mailing list