mixin template's alias parameter ... ignored ?

Mike Parker aldacron at gmail.com
Tue Jul 13 02:34:07 UTC 2021


On Tuesday, 13 July 2021 at 02:22:46 UTC, Mike Parker wrote:
> On Tuesday, 13 July 2021 at 01:03:11 UTC, someone wrote:
>>
>> Being *local* to ... ain't imply visibility too regardless 
>> scope not being a visibility attribute ? I mean, scope is 
>> restricting the variable to be leaked outside the 
>> function/whatever and to me it seems like restricted to be 
>> seen from the outside.

And I meant to add... local variables are by default visible only 
inside the scope in which they are declared and, by extension, 
any inner scopes within that scope, and can never be visible 
outside.

```d
{
     // Scope A
     // x can never be visible here
     {
         // Scope B
         int x;
         {
             // Scope C
             // x is visible here
         }
     }
}
```

The only possible use for your concept of scope applying to 
visibility would be to prevent x from being visible in in Scope 
C. But since we already have the private attribute, it would make 
more sense to use that instead, e.g., `private int x` would not 
be visible in scope C.

I don't know of any language that has that kind of feature, or if 
it would even be useful. But at any rate, there's no need for a 
visibility attribute to prevent outer scopes from seeing a local 
variable, as that's already impossible.


More information about the Digitalmars-d-learn mailing list