DIP1000: Scoped Pointers (Discussion)

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Sun Aug 14 12:49:27 PDT 2016


On 8/14/2016 12:39 PM, Walter Bright wrote:
> On 8/14/2016 7:42 AM, Dicebot wrote:
>> 2) Ignoring `scope` for variables with no indirections.
>>
>> The fact that DMD is extremely accepting when it comes to nonsense
>> declarations/attributes has been is notable contribution to harming
>> learning curve. It often tricks new developers into thinking that their
>> code is checked for something when in fact compiler simply silently
>> skips extra annotations.
>>
>> Instead, nonsense application of `scope` to data with no indirections
>> should be deprecated completely as part of overall deprecation process
>> for implementing the proposal.
>
> The difficulty with that is dealing with generic types.

Consider another case:

   struct S {
     int i;
     int* p;
   }

   scope S s;

   return s.i; // ok
   return s.p; // error!

The 'scope' only applies to the indirection parts of a type. Therefore,

   scope int i;

should not be an error.


More information about the Digitalmars-d mailing list