Re: Alias example should supposedly be illegal, but runs fine

2017-12-19 Thread Mike Franklin via Digitalmars-d-learn
On Tuesday, 19 December 2017 at 10:37:05 UTC, Michael wrote: On Tuesday, 19 December 2017 at 02:12:29 UTC, Mike Franklin wrote: On Tuesday, 19 December 2017 at 02:04:34 UTC, codephantom wrote: writeln(S.j); // Error: Instance symbols cannot be used through types. I don't understand why

Re: Alias example should supposedly be illegal, but runs fine

2017-12-19 Thread Michael via Digitalmars-d-learn
On Tuesday, 19 December 2017 at 02:12:29 UTC, Mike Franklin wrote: On Tuesday, 19 December 2017 at 02:04:34 UTC, codephantom wrote: writeln(S.j); // Error: Instance symbols cannot be used through types. I don't understand why you would say that is a bug. I meant that the example is

Re: Alias example should supposedly be illegal, but runs fine

2017-12-19 Thread Michael via Digitalmars-d-learn
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

Re: Alias example should supposedly be illegal, but runs fine

2017-12-18 Thread Mike Franklin via Digitalmars-d-learn
On Tuesday, 19 December 2017 at 02:04:34 UTC, codephantom wrote: writeln(S.j); // Error: Instance symbols cannot be used through types. I don't understand why you would say that is a bug. I meant that the example is wrong, and a bug report should be filed to fix the example. Mike

Re: Alias example should supposedly be illegal, but runs fine

2017-12-18 Thread codephantom via Digitalmars-d-learn
On Tuesday, 19 December 2017 at 01:30:07 UTC, Mike Franklin wrote: writeln(S.j); // Error: Instance symbols cannot be used through types. I don't understand why you would say that is a bug. i.e. // import std.stdio; struct S { int j; } void main() {

Re: Alias example should supposedly be illegal, but runs fine

2017-12-18 Thread Mike Franklin via Digitalmars-d-learn
On Monday, 18 December 2017 at 23:44:46 UTC, Michael wrote: I have been looking at the following example found right at the end of the section here: https://dlang.org/spec/declaration.html#alias struct S { static int i; } S s; alias a = s.i; // illegal, s.i is an expression alias b = S.i;

Re: Alias example should supposedly be illegal, but runs fine

2017-12-18 Thread Meta via Digitalmars-d-learn
On Monday, 18 December 2017 at 23:44:46 UTC, Michael wrote: Hello, I have been looking at the following example found right at the end of the section here: https://dlang.org/spec/declaration.html#alias struct S { static int i; } S s; alias a = s.i; // illegal, s.i is an expression alias b

Re: Alias example should supposedly be illegal, but runs fine

2017-12-18 Thread codephantom via Digitalmars-d-learn
On Monday, 18 December 2017 at 23:44:46 UTC, Michael wrote: alias a = s.i; // illegal, s.i is an expression Actually, as I understand it, the example provided in 10. is legal (because it aliases a type), and the example provided in 3. is illegal (because it aliases an expression) perhaps

Re: Alias example should supposedly be illegal, but runs fine

2017-12-18 Thread codephantom via Digitalmars-d-learn
On Monday, 18 December 2017 at 23:44:46 UTC, Michael wrote: alias a = s.i; // illegal, s.i is an expression alias a = s.i; (this is an alias to a type, since s.i is an int) Hence it is actually 'legal', as far as I understand. i.e... "AliasDeclarations create a symbol that is an alias for

Alias example should supposedly be illegal, but runs fine

2017-12-18 Thread Michael via Digitalmars-d-learn
Hello, I have been looking at the following example found right at the end of the section here: https://dlang.org/spec/declaration.html#alias struct S { static int i; } S s; alias a = s.i; // illegal, s.i is an expression alias b = S.i; // ok b = 4; // sets S.i to 4 and it runs