A Refcounted Array Type

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Mon Mar 2 19:38:38 PST 2015


On Mon, 02 Mar 2015 15:43:42 -0500, Steven Schveighoffer wrote:

> On 2/27/15 11:18 PM, ketmar wrote:
>> On Fri, 27 Feb 2015 20:51:54 +0000, deadalnix wrote:
>>
>>> On Friday, 27 February 2015 at 04:13:03 UTC, Steven Schveighoffer
>>> wrote:
>>>> In that case, you shouldn't be subject to any kind of race
>>>> conditions.
>>>> But we can't make the library/language based on this assumption. Your
>>>> case is the exceptional case.
>>>>
>>>>
>>> His case is not @safe, so we can ignore that problem.
>>
>> the compiler tends to disagree:
>>
>> === test.d ===
>> int myglobal;
>>
>> class A {
>>    ~this () @safe { if (myglobal == 42) assert(0); }
>> }
>>
>> void main () {
>>    auto a = new A;
>> }
>> ======
>>
>> dmd -w -c -o- test.d
>>
>> wow! no warnings, no errors!
>>
>>
> 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20150303/e9e18926/attachment.sig>


More information about the Digitalmars-d mailing list