The next iteration of scope

Zach the Mystic via Digitalmars-d digitalmars-d at
Mon Mar 16 12:42:59 PDT 2015

On Monday, 16 March 2015 at 17:00:12 UTC, Marc Sch├╝tz wrote:
> BUt there is indeed still some confusion on my side. It's about 
> the question whether `this` should implicitly be passed as 
> `scope` or not. Because if it is, scope members are probably 
> useless, because they are already implied. I think I should 
> remove this suggestion, because it would break too much code 
> (in @system).

I always tend to think of member functions as if they weren't:

struct S {
   T t;
   ref T fun() return {
     return t;

In my head, I just translate fun() above to:

ref T fun(return S* __this) {
   return __this.t;

Therefore whatever the scope of `__this`, that's the scope of the 
return, just like it would be for any other parameter. Then:

S s;;

... is really just `fun(s);` in disguise. That's why it's hard 
for me to grasp `scope` members, because they seem to me to be 
just as scope as their parent, whether global or local. How a 
member could be scope when the parent is global is hard for me to 

More information about the Digitalmars-d mailing list