Alias example should supposedly be illegal, but runs fine

Michael michael at toohuman.io
Tue Dec 19 10:34:12 UTC 2017


On Tuesday, 19 December 2017 at 01:29:04 UTC, Meta wrote:
> On Monday, 18 December 2017 at 23:44:46 UTC, Michael wrote:
>> [...]
>
> I think the reason that this works is because i is static, 
> meaning that you don't need the `this` reference of S to access 
> it and thus it can be aliased. Declaring a static class or 
> struct variable is pretty much the same as declaring a global 
> variable, just with a tighter scope. If you look at it that 
> way, then this makes a lot more sense. If you declare a global 
> variable i at module scope, of course you can create an alias 
> for it.

Yes I think you're right. I wasn't sure what was going on, just 
noticed that the example definitely isn't right. I'll file a bug 
support and try and fix it.


More information about the Digitalmars-d-learn mailing list