www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - alias have new syntax?

reply "cmplx" <magiisto mail.ru> writes:
During the study D, I stumbled upon this design
alias myInt = int;
but the specification says nothing about such use alias. Is the 
syntax has been changed?
Jan 18 2014
next sibling parent "cmplx" <magiisto mail.ru> writes:
On Saturday, 18 January 2014 at 22:50:50 UTC, cmplx wrote:
 During the study D, I stumbled upon this design
 alias myInt = int;
 but the specification says nothing about such use alias. Is the 
 syntax has been changed?
Sorry, I wrong : AliasDeclaration: .... alias AliasInitializerList AliasInitializer: Identifier = Type
Jan 18 2014
prev sibling next sibling parent "Xinok" <xinok live.com> writes:
On Saturday, 18 January 2014 at 22:50:50 UTC, cmplx wrote:
 During the study D, I stumbled upon this design
 alias myInt = int;
 but the specification says nothing about such use alias. Is the 
 syntax has been changed?
It seems that it's documented here, albeit not clearly: http://dlang.org/declaration.html#AliasInitializer I don't see any mention of it here: http://dlang.org/declaration.html#alias I recall there being some issues with alias this = identifier, not sure if that's been resolved. Regardless, I think the documentation at the latter link needs to be updated.
Jan 18 2014
prev sibling parent reply "bearophile" <bearophileHUGS lycos.com> writes:
cmplx:

 During the study D, I stumbled upon this design
 alias myInt = int;
 but the specification says nothing about such use alias. Is the 
 syntax has been changed?
Yes, it's a recent very small syntax improvement. Eventually I hope the older syntax will be deprecated. The old syntax is still used for the "static this" in structs. Bye, bearophile
Jan 18 2014
next sibling parent reply "Brian Schott" <briancschott gmail.com> writes:
On Saturday, 18 January 2014 at 23:00:11 UTC, bearophile wrote:
 Yes, it's a recent very small syntax improvement. Eventually I 
 hope the older syntax will be deprecated. The old syntax is 
 still used for the "static this" in structs.

 Bye,
 bearophile
DScanner now issues a warning when run with the --styleCheck or --syntaxCheck options suggesting that the user switch from "alias a b" to "alias b = a". It also warns on implicit string concatenation, which has saved me a lot of debugging in situations like this: enum someStrings = ["abc", "def" "ghi", "jkl"];
Jan 18 2014
parent reply "bearophile" <bearophileHUGS lycos.com> writes:
Brian Schott:

 It also warns on implicit string concatenation, which has saved 
 me a lot of debugging in situations like this:

 enum someStrings = ["abc", "def" "ghi", "jkl"];
This should be an error in the language. Please add your experience (and vote, if you want) to this thread: http://d.puremagic.com/issues/show_bug.cgi?id=3827 Bye, bearophile
Jan 18 2014
parent reply "Brian Schott" <briancschott gmail.com> writes:
On Saturday, 18 January 2014 at 23:13:41 UTC, bearophile wrote:
 This should be an error in the language. Please add your 
 experience (and vote, if you want) to this thread:
 http://d.puremagic.com/issues/show_bug.cgi?id=3827
I've added my vote.
Jan 18 2014
parent "bearophile" <bearophileHUGS lycos.com> writes:
Brian Schott:

 I've added my vote.
A note about your experience is probably more important than the vote. You can add some bugs you have had to debug, some comment about the frequency of this problem, etc. Bye, bearophile
Jan 18 2014
prev sibling parent "Nicolas Sicard" <dransic gmail.com> writes:
On Saturday, 18 January 2014 at 23:00:11 UTC, bearophile wrote:
 cmplx:

 During the study D, I stumbled upon this design
 alias myInt = int;
 but the specification says nothing about such use alias. Is 
 the syntax has been changed?
Yes, it's a recent very small syntax improvement. Eventually I hope the older syntax will be deprecated. The old syntax is still used for the "static this" in structs. Bye, bearophile
You meant "alias this".
Jan 19 2014