Preferred Alias Declaration Style

Uknown sireeshkodali1 at gmail.com
Wed Jun 27 12:25:26 UTC 2018


On Wednesday, 27 June 2018 at 10:22:38 UTC, Vijay Nayar wrote:
> Most of the documentation at 
> https://dlang.org/spec/declaration.html#alias uses examples of 
> the form:  `alias aliasName = other;`, where `aliasName` 
> becomes the new name to reference `other`.  Alternatively, one 
> may write `alias other aliasName;`.  My understanding is that 
> the syntax with `=` is the preferred one stylistically.
>
> However, when it comes to `alias this` declarations, the only 
> syntax supported is `alias other this;`, and one cannot write 
> `alias this = other;`.
>
> Does this mean that the `alias other aliasName;` syntax is 
> preferred, or does it simply mean that this is a low priority 
> issue that hasn't been addressed yet?

`alias Alias = SomeType;` is preferred. It is the new style, and 
is more clear on what is the alias and what is the new type, 
especially when complex types come into play. For `alias this` 
though, there is only one syntax, `alias other this;`, since it 
does something conceptually different from regular aliases.


More information about the Digitalmars-d-learn mailing list