RFC: scope and borrowing

via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 28 02:16:36 PDT 2014


On Thursday, 28 August 2014 at 06:52:31 UTC, Jacob Carlborg wrote:
> On 24/08/14 15:14, "Marc Schütz" <schuetzm at gmx.net>" wrote:
>> In the "Opportunities for D" thread, Walter again mentioned 
>> the topics
>> ref counting, GC, uniqueness, and borrowing, from which a 
>> lively
>> discussion developed [1]. I took this thread as an opportunity 
>> to write
>> down some ideas about these topics. The result is a rather 
>> extensive
>> proposal for the implementation of borrowing, and its 
>> implementations:
>>
>> http://wiki.dlang.org/User:Schuetzm/scope
>
> I assume with this proposal it should be safe to do more stack 
> allocations and have the compiler verify references don't 
> escape the scope. Would there be a good idea to and a new 
> function, besides the destructor, that will be called for 
> variables declared as "scope" when they go out of scope.
>
> The problem with destructors are that they can be called both 
> when an object is deleted by the GC and when an object goes of 
> out scope.

I'd rather introduce a special method that is called only by the 
GC. Cleaning up after an object that goes out of scope has always 
been the task of the regular destructor, it's undeterministic 
destruction that needs special treatment.


More information about the Digitalmars-d mailing list