On Tuesday, 13 July 2021 at 02:34:07 UTC, Mike Parker wrote:
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
        }
    }
}
```

Yes. This one I understood from the beginning -it was on Ali's book and previously I remember seeing it in Andrei's one too IIRC.

http://ddili.org/ders/d.en/name_space.html

The thing that I supposed started my confusion was the lack of a statement for it, nothing more; something like: whatever int x; ... it was more of form than concept.

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.

No. My concept is/was the same that the one above. It was form not function.

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.

Me neither.

Reply via email to