"The last feature": scope structs

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Feb 8 04:57:27 PST 2010


Lars T. Kyllingstad wrote:
> Andrei Alexandrescu wrote:
>> Following work on typechecking synchronized methods, Walter and I were 
>> discussing about managing escaping references to objects that wouldn't 
>> actually agree to escaping. The problem is that today a value has no 
>> idea that its address is being taken, so it has no saying in that.
>>
>> To compensate for that, my idea was to allow @disable on opUnary!"&". 
>> Walter suggested allowing "scope" as a property of a struct:
>>
>> scope struct Transitory
>> {
>>     ...
>> }
>>
>> A scope struct cannot have its address taken. You can take addresses 
>> of its members (access permitting), but you can't take the address of 
>> any other struct that has at least one scope struct as a direct 
>> member. For example:
>>
>> struct A
>> {
>>     int x;
>>     Transitory tr;
>> }
>>
>> A will also be scope. So scope has this funny way of propagating 
>> outwards, as opposed to qualifiers, which propagate inwards.
> 
> Though the feature seems useful, I worry about the asymmetry with scope 
> classes.

Scope classes will be eliminated from the language.

Andrei



More information about the Digitalmars-d mailing list