digitalmars.D - Alias syntax removal
- "bearophile" <bearophileHUGS lycos.com> Feb 10 2013
- "Maxim Fomin" <maxim maxim-fomin.ru> Feb 10 2013
- kenji hara <k.hara.pg gmail.com> Feb 10 2013
- "bearophile" <bearophileHUGS lycos.com> Feb 10 2013
- kenji hara <k.hara.pg gmail.com> Feb 10 2013
- Timon Gehr <timon.gehr gmx.ch> Feb 24 2013
- "Zoadian" <github zoadian.de> Feb 10 2013
- "Tove" <tove fransson.se> Feb 10 2013
- Andrej Mitrovic <andrej.mitrovich gmail.com> Feb 10 2013
- Stewart Gordon <smjg_1998 yahoo.com> Feb 11 2013
- Nick Treleaven <ntrel-public yahoo.co.uk> Feb 11 2013
- kenji hara <k.hara.pg gmail.com> Feb 11 2013
- "Kagamin" <spam here.lot> Feb 12 2013
- "Simen Kjaeraas" <simen.kjaras gmail.com> Feb 12 2013
- "Michael" <pr m1xa.com> Feb 23 2013
Now I have a good amount of code broken by: alias x = 5; alias this = foo; I don't expect all changes of a beta to be kept in a final compiler version, but I think the removal of a syntax should be announced (and discussed) in this newsgroup (if the removal of such syntax was discussed in this newsgroup, then I have missed it): https://github.com/D-Programming-Language/dmd/issues/1413 Bye, bearophile
Feb 10 2013
On Sunday, 10 February 2013 at 13:13:12 UTC, bearophile wrote:Now I have a good amount of code broken by
Thanks to (absence of) D development model.I don't expect ...
Expecting something from how D is developed is not always a good idea:)https://github.com/D-Programming-Language/dmd/issues/1413 Bye, bearophile
I am also not aware of any discussion except for that. For this particular case, I honestly also considered that killing old syntax would not do much harm, but it is hard to estimate. In general, until D has a stable and clear development policy, I expect similar problems would happen over and over.
Feb 10 2013
--f46d044306b0bc60f304d55f788d Content-Type: text/plain; charset=UTF-8 2013/2/10 bearophile <bearophileHUGS lycos.com>Now I have a good amount of code broken by: alias x = 5;
This syntax never been valid in past, because alias declaration cannot make alias of an expression.alias this = foo;
This syntax was introduced very recent, in 2.061. ======From 2.061, we have get new alias syntax by fixing issue 3011.
Now we can write alias declaration as follows: alias Integer = int; alias IntArray = int[]; These syntax are continuously valid in 2.062. But, while a discussion for the compiler fix, a wrong syntax change, which has similar look but definitely different meaning, had been introduced. https://github.com/D-Programming-Language/dmd/pull/1187 struct S { int value; alias value this; // old syntax alias this = value; // new syntax, from 2.061 } I opened the pull request #1413 in the beta term for 2.061, but it had _accidentally_ released without deeply discussion. https://github.com/D-Programming-Language/dmd/pull/1413 I think and believe that we MUST reset things. Kenji Hara --f46d044306b0bc60f304d55f788d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">2013/2/10 bearophile <span dir=3D"ltr"><<a href=3D"mail= to:bearophileHUGS lycos.com" target=3D"_blank">bearophileHUGS lycos.com</a>= ></span><br><div class=3D"gmail_extra"><div class=3D"gmail_quote"><block= quote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-w= idth:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding= -left:1ex"> Now I have a good amount of code broken by:<br> <br> alias x =3D 5;<br> </blockquote><div><br></div><div>This syntax never been valid in past, beca= use alias declaration cannot make alias of an expression.</div><div>=C2=A0<= /div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;bo= rder-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:so= lid;padding-left:1ex"> alias this =3D foo;<br></blockquote><div><br></div><div style>=C2=A0This sy= ntax was introduced very recent, in 2.061.</div><div style><br></div><div s= tyle>=3D=3D=3D=3D=3D=3D</div><div style><br></div><div style>From 2.061, we= have get new alias syntax by fixing issue 3011.</div> <div style><a href=3D"http://d.puremagic.com/issues/show_bug.cgi?id=3D3011"=http://d.puremagic.com/issues/show_bug.cgi?id=3D3011</a><br></div><div sty=
<div style>
=3D int[];</div><div style><br></div><div style>These syntax are continuous= ly valid in 2.062.</div><div style><br></div><div>But, while a discussion f= or the compiler fix, a wrong syntax change, which has similar look but defi= nitely different meaning, had been introduced.</div> <div style><a href=3D"https://github.com/D-Programming-Language/dmd/pull/11= 87">https://github.com/D-Programming-Language/dmd/pull/1187</a><br></div><d= iv style><br></div><div style>struct S {</div><div style>=C2=A0 =C2=A0 int = value;</div> <div style>=C2=A0 =C2=A0 alias value this; =C2=A0 // old syntax</div><div s= tyle>=C2=A0 =C2=A0 alias this =3D value; =C2=A0// new syntax, from 2.061</d= iv><div style>}</div><div style><br></div><div style>I opened the pull requ= est #1413 in the beta term for 2.061, but it had _accidentally_ released wi= thout deeply discussion.</div> <div style><a href=3D"https://github.com/D-Programming-Language/dmd/pull/14= 13">https://github.com/D-Programming-Language/dmd/pull/1413</a><br></div><d= iv style><br></div><div style>I think and believe that we MUST reset things= .</div> <div style><br></div><div style>Kenji Hara</div></div></div></div> --f46d044306b0bc60f304d55f788d--
Feb 10 2013
kenji hara:This syntax never been valid in past, because alias declaration cannot make alias of an expression.
Right, sorry, my mistake.Now we can write alias declaration as follows: alias Integer = int; alias IntArray = int[]; These syntax are continuously valid in 2.062.
OK. So they aren't going away as I have feared.But, while a discussion for the compiler fix, a wrong syntax change, which has similar look but definitely different meaning, had been introduced. https://github.com/D-Programming-Language/dmd/pull/1187 struct S { int value; alias value this; // old syntax alias this = value; // new syntax, from 2.061 } I opened the pull request #1413 in the beta term for 2.061, but it had _accidentally_ released without deeply discussion. https://github.com/D-Programming-Language/dmd/pull/1413 I think and believe that we MUST reset things.
I see. Thank you for the work. Bye, bearophile
Feb 10 2013
--f46d043c7d14e155c504d55fcd63 Content-Type: text/plain; charset=UTF-8 2013/2/10 kenji hara <k.hara.pg gmail.com>I opened the pull request #1413 in the beta term for 2.061, but it had _accidentally_ released without deeply discussion. https://github.com/D-Programming-Language/dmd/pull/1413 I think and believe that we MUST reset things.
Why I argue that the syntax `alias this = sym;` is wrong? Because: 1. A normal alias declaration (creating aliased name for existing symbol) and alias this feature (making a *subtyped* struct through implicit access to its field) are entirely different and has distinct semantics. They merely share a keyword 'alias'. 2. Instead, we can have much more consistent, useful, and scalable syntax. At the same time, I proposed a new syntax `alias this : ident;` for alias this feature. https://github.com/D-Programming-Language/d-programming-language.org/pull/200 struct S { int value; alias this : value; // proposed syntax } Benefits of the proposed syntax are: 2a. It is consistent with class inheritance syntax `class C : B {}`. 2b. It is scalable for multiple alias this feature, as like `alias this : sym1, sym2, ...;` . If D community highly require the syntax `alias this = sym`, I'll agree to adding it again. But for that, we should discuss about its cost and benefit. Sorry for my poor writing. Regards. Kenji Hara --f46d043c7d14e155c504d55fcd63 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">2013/2/10 kenji hara <span dir=3D"ltr"><<a href=3D"mail= to:k.hara.pg gmail.com" target=3D"_blank">k.hara.pg gmail.com</a>></span=<br><div class=3D"gmail_extra"><div class=3D"gmail_quote"><blockquote clas=
order-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"=
<div>I opened the pull request #1413 in the beta term for 2.061, but it had= _accidentally_ released without deeply discussion.</div> <div><a href=3D"https://github.com/D-Programming-Language/dmd/pull/1413" ta= rget=3D"_blank">https://github.com/D-Programming-Language/dmd/pull/1413</a>= <br></div><div><br></div><div>I think and believe that we MUST reset things= .</div> </div></div></div></blockquote><div><br></div><div style>Why I argue that t= he syntax `alias this =3D sym;` is wrong? Because:</div><div style><br></di= v><div style>1. A normal alias declaration (creating aliased name for exist= ing symbol) and alias this feature</div> <div style>(making a *subtyped* struct through implicit access to its field= ) are entirely different and has distinct semantics.</div><div style>They m= erely share a keyword 'alias'.</div><div style><br></div><div style=
/div><div style>At the same time, I proposed a new syntax `alias this : ide= nt;` for alias this feature.</div><div style><a href=3D"https://github.com/= D-Programming-Language/d-programming-language.org/pull/200">https://github.= com/D-Programming-Language/d-programming-language.org/pull/200</a><br> </div><div style><br></div><div style>struct S {</div><div style>=C2=A0 =C2= =A0 int value;</div><div style>=C2=A0 =C2=A0 alias this : value; =C2=A0 // = proposed syntax</div><div style>}</div><div style><br></div><div style>Bene= fits of the proposed syntax are:</div> <div style>2a. It is consistent with class inheritance syntax `class C : B = {}`.</div><div style>2b. It is scalable for multiple alias this feature, as= like `alias this :=C2=A0sym1,=C2=A0sym2, ...;` .</div><div style><br></div=<div style>
ee to adding it again.</div><div style>But for that, we should discuss abou= t its cost and benefit.</div><div style><br></div><div style>Sorry for my p= oor writing.</div> <div style>Regards.</div><div style><br></div><div style>Kenji Hara</div></= div></div></div> --f46d043c7d14e155c504d55fcd63--
Feb 10 2013
On 02/10/2013 03:42 PM, kenji hara wrote:2013/2/10 kenji hara <k.hara.pg gmail.com <mailto:k.hara.pg gmail.com>> I opened the pull request #1413 in the beta term for 2.061, but it had _accidentally_ released without deeply discussion. https://github.com/D-Programming-Language/dmd/pull/1413 I think and believe that we MUST reset things. Why I argue that the syntax `alias this = sym;` is wrong?
Do you have any arguments that do not also apply to alias sym this; ?Because: 1. A normal alias declaration (creating aliased name for existing symbol) and alias this feature (making a *subtyped* struct through implicit access to its field)
Actually that is not what subtyping means.are entirely different and has distinct semantics.
Yet they already deliberately share the same piece of syntax. The problems cannot be attributed to the alias assignment syntax addition.They merely share a keyword 'alias'.
No, they share the entire declaration syntax. alias foo this; alias foo that;2. Instead, we can have much more consistent,
alias foo that; // ok alias foo this; // ok alias that=foo; // ok alias this=foo; // uh...useful,
All are of the same usefulness.and scalable syntax. At the same time, I proposed a new syntax `alias this : ident;` for alias this feature.
Yes, what is the point? Why would a new syntax that's deliberately inconsistent with alias syntax require an 'alias' keyword? It is not an alias. The other special aggregate members are just specially named symbols.https://github.com/D-Programming-Language/d-programming-language.org/pull/200 struct S { int value; alias this : value; // proposed syntax } Benefits of the proposed syntax are: 2a. It is consistent with class inheritance syntax `class C : B {}`.
It's hardly consistent, and you were opposed to entirely different constructs having similar syntax above!2b. It is scalable for multiple alias this feature, as like `alias this : sym1, sym2, ...;` .
TDPL says: alias sym1 this; alias sym2 this; ...If D community highly require the syntax `alias this = sym`, I'll agree to adding it again. But for that, we should discuss about its cost and benefit. ...
The syntax to access the alias this functionality is quite whacky. Applying a partial fix without going all the way just increases confusion.
Feb 24 2013
`alias this : sym1, sym2, ...;` .
+1 clean and simple and consistent.
Feb 10 2013
On Sunday, 10 February 2013 at 14:42:50 UTC, kenji hara wrote:2013/2/10 kenji hara <k.hara.pg gmail.com> Why I argue that the syntax `alias this = sym;` is wrong? Because: Benefits of the proposed syntax are: 2a. It is consistent with class inheritance syntax `class C : B {}`. 2b. It is scalable for multiple alias this feature, as like `alias this : sym1, sym2, ...;` .
2a. I agree. 2b. I always assumed multiple alias would be introduced like this... alias this = sym1; alias this = sym2; ... which also is "needed" if you use a "3rd party library mixin" in your struct(which internally uses alias this), so even with the ':' syntax it's anyway required to support being able to use it multiple times: alias this : sym1; alias this : sym2; So I don't think 2b speaks in favor of the new syntax.
Feb 10 2013
On 2/10/13, Tove <tove fransson.se> wrote:... which also is "needed" if you use a "3rd party library mixin" in your struct(which internally uses alias this), so even with the ':' syntax it's anyway required to support being able to use it multiple times: alias this : sym1; alias this : sym2;
I've argued that it should be rare that someone uses multiple subtyping, so I don't see the need to introduce more syntax into the language when they can simply do this for the special occasion when they need it: alias this = this; alias this = bar;
Feb 10 2013
On 10/02/2013 13:13, bearophile wrote:Now I have a good amount of code broken by: alias x = 5; alias this = foo;
Was this ever documented? How many people ever knew this syntax existed? Not me.... Stewart.
Feb 11 2013
On 11/02/2013 10:46, Stewart Gordon wrote:On 10/02/2013 13:13, bearophile wrote:Now I have a good amount of code broken by: alias x = 5; alias this = foo;
Was this ever documented? How many people ever knew this syntax existed? Not me....
The 2.061 changelog has a 'new/changed features' link to bugzilla items, where there's an item 'alias should have assignment syntax'. There are two issues with this approach: 1. Alias assignment syntax is (probably) a more interesting change to many D users than quite a few of the other new/changed items listed. It is buried amongst some less interesting items. 2. Being a bugzilla item title it doesn't contain syntax examples, which is what a changelog reader would like to see. The new deprecated switches item did get a paragraph in the changelog, but other significant changes did not.
Feb 11 2013
--f46d0434c0aa5c6c2204d570bebb Content-Type: text/plain; charset=UTF-8 2013/2/11 Stewart Gordon <smjg_1998 yahoo.com>On 10/02/2013 13:13, bearophile wrote:Now I have a good amount of code broken by: alias x = 5; alias this = foo;
Was this ever documented? How many people ever knew this syntax existed? Not me...
* * *AliasDeclaration*: alias *BasicType*<http://dlang.org/declaration#BasicType> *Declarator* <http://dlang.org/declaration#Declarator> alias * AliasInitializerList* <http://dlang.org/declaration#AliasInitializerList>* AliasDeclaration*: alias *BasicType*<http://dlang.org/declaration#BasicType> *Declarator* <http://dlang.org/declaration#Declarator> alias * AliasInitializerList* <http://dlang.org/declaration#AliasInitializerList> http://dlang.org/declaration AliasDeclaration: alias BasicType Declarator alias AliasInitializerList AliasInitializerList: AliasInitializer AliasInitializer , AliasInitializerList AliasInitializer: Identifier = Type Kenji Hara --f46d0434c0aa5c6c2204d570bebb Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">2013/2/11 Stewart Gordon <span dir=3D"ltr"><<a href=3D"= mailto:smjg_1998 yahoo.com" target=3D"_blank">smjg_1998 yahoo.com</a>></= span><br><div class=3D"gmail_extra"><div class=3D"gmail_quote"><blockquote = class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1= px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:= 1ex"> <div class=3D"im">On 10/02/2013 13:13, bearophile wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-= left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;p= adding-left:1ex"> Now I have a good amount of code broken by:<br> <br> alias x =3D 5;<br> alias this =3D foo;<br> </blockquote> <br></div> Was this ever documented? =C2=A0How many people ever knew this syntax exist= ed? =C2=A0Not me...</blockquote><div style><a name=3D"AliasDeclaration" sty= le=3D"color:rgb(0,0,102);font-family:Verdana,'Deja Vu','Bitstre= am Vera Sans',sans-serif;font-size:0px;background-color:rgb(31,37,43)">= </a><a name=3D"AliasDeclaration" style=3D"color:rgb(0,0,102)"><i><br> </i></a></div><div style><a name=3D"AliasDeclaration" style=3D"color:rgb(0,= 0,102);font-family:Verdana,'Deja Vu','Bitstream Vera Sans',= sans-serif;font-size:0px;background-color:rgb(31,37,43)"></a><a name=3D"Ali= asDeclaration" style=3D"color:rgb(0,0,102)"><i>AliasDeclaration</i></a><spa= n style=3D"color:rgb(31,37,43)">:=C2=A0</span><span class=3D"" style=3D"col= or:rgb(31,37,43)"><span class=3D"" style=3D"font-family:Consolas,'Bitst= ream Vera Sans Mono','Andale Mono',Monaco,'DejaVu Sans Mono= ','Lucida Console',monospace;font-weight:bold">alias</span></sp= an><span style=3D"color:rgb(31,37,43)">=C2=A0</span><a href=3D"http://dlang= .org/declaration#BasicType" style=3D"color:rgb(102,0,102)"><i>BasicType</i>= </a><span style=3D"color:rgb(31,37,43)">=C2=A0</span><a href=3D"http://dlan= g.org/declaration#Declarator" style=3D"color:rgb(102,0,102)"><i>Declarator<= /i></a><span style=3D"color:rgb(31,37,43)">=C2=A0</span><span class=3D"" st= yle=3D"color:rgb(31,37,43)"><span class=3D"" style=3D"font-family:Consolas,= 'Bitstream Vera Sans Mono','Andale Mono',Monaco,'DejaVu= Sans Mono','Lucida Console',monospace;font-weight:bold">alias<= /span></span><span style=3D"color:rgb(31,37,43)">=C2=A0</span><a href=3D"ht= tp://dlang.org/declaration#AliasInitializerList" style=3D"color:rgb(102,0,1= 02)"><i>AliasInitializerList</i></a><i>AliasDeclaration</i><span style=3D"c= olor:rgb(31,37,43);font-family:Verdana,'Deja Vu','Bitstream Ver= a Sans',sans-serif;font-size:0px;background-color:rgb(31,37,43)">:=C2= =A0</span><span class=3D"" style=3D"color:rgb(31,37,43);font-family:Verdana= ,'Deja Vu','Bitstream Vera Sans',sans-serif;font-size:0px;b= ackground-color:rgb(31,37,43)"><span class=3D"" style=3D"font-family:Consol= as,'Bitstream Vera Sans Mono','Andale Mono',Monaco,'Dej= aVu Sans Mono','Lucida Console',monospace;font-weight:bold">ali= as</span></span><span style=3D"color:rgb(31,37,43);font-family:Verdana,'= ;Deja Vu','Bitstream Vera Sans',sans-serif;font-size:0px;backgr= ound-color:rgb(31,37,43)">=C2=A0</span><a href=3D"http://dlang.org/declarat= ion#BasicType" style=3D"color:rgb(102,0,102);font-family:Verdana,'Deja = Vu','Bitstream Vera Sans',sans-serif;font-size:0px;background-c= olor:rgb(31,37,43)"><i>BasicType</i></a><span style=3D"color:rgb(31,37,43);= font-family:Verdana,'Deja Vu','Bitstream Vera Sans',sans-se= rif;font-size:0px;background-color:rgb(31,37,43)">=C2=A0</span><a href=3D"h= ttp://dlang.org/declaration#Declarator" style=3D"color:rgb(102,0,102);font-= family:Verdana,'Deja Vu','Bitstream Vera Sans',sans-serif;f= ont-size:0px;background-color:rgb(31,37,43)"><i>Declarator</i></a><span sty= le=3D"color:rgb(31,37,43);font-family:Verdana,'Deja Vu','Bitstr= eam Vera Sans',sans-serif;font-size:0px;background-color:rgb(31,37,43)"==C2=A0</span><span class=3D"" style=3D"color:rgb(31,37,43);font-family:Ver=
px;background-color:rgb(31,37,43)"><span class=3D"" style=3D"font-family:Co= nsolas,'Bitstream Vera Sans Mono','Andale Mono',Monaco,'= ;DejaVu Sans Mono','Lucida Console',monospace;font-weight:bold"=alias</span></span><span style=3D"color:rgb(31,37,43);font-family:Verdana,=
ckground-color:rgb(31,37,43)">=C2=A0</span><a href=3D"http://dlang.org/decl= aration#AliasInitializerList" style=3D"color:rgb(102,0,102);font-family:Ver= dana,'Deja Vu','Bitstream Vera Sans',sans-serif;font-size:0= px;background-color:rgb(31,37,43)"><i>AliasInitializerList</i></a><a href= =3D"http://dlang.org/declaration">http://dlang.org/declaration</a><br> <br></div><div style><div>AliasDeclaration:</div><div>=C2=A0 =C2=A0 alias B= asicType Declarator</div><div>=C2=A0 =C2=A0 alias AliasInitializerList</div=<div><br></div><div>AliasInitializerList:</div><div>=C2=A0 =C2=A0 AliasIni=
iv> <div><br></div><div>AliasInitializer:</div><div>=C2=A0 =C2=A0 Identifier = =3D Type</div><div><br></div><div style>Kenji Hara</div></div></div></div><= /div> --f46d0434c0aa5c6c2204d570bebb--
Feb 11 2013
On Sunday, 10 February 2013 at 14:42:50 UTC, kenji hara wrote:Why I argue that the syntax `alias this = sym;` is wrong? Because: 1. A normal alias declaration (creating aliased name for existing symbol) and alias this feature (making a *subtyped* struct through implicit access to its field) are entirely different and has distinct semantics. They merely share a keyword 'alias'.
I think alias this works like alias. Shouldn't subtyped object support casting to any its type? Contrarily alias this simply redirects access like alias and has nothing to do with types, so it's pretty valid to see it as an alias.
Feb 12 2013
On 2013-35-10 17:02, Andrej Mitrovic <andrej.mitrovich gmail.com> wrote:I've argued that it should be rare that someone uses multiple subtyping, so I don't see the need to introduce more syntax into the language when they can simply do this for the special occasion when they need it: alias this = this; alias this = bar;
The point of this change is not really to allow multiple subtyping, but to indicate that alias this is different from other aliases. It is a Good Thing(tm). -- Simen
Feb 12 2013
Why I argue that the syntax `alias this = sym;` is wrong? Because: 1. A normal alias declaration (creating aliased name for existing symbol) and alias this feature (making a *subtyped* struct through implicit access to its field) are entirely different and has distinct semantics. They merely share a keyword 'alias'. 2. Instead, we can have much more consistent, useful, and scalable syntax. At the same time, I proposed a new syntax `alias this : ident;` for alias this feature. https://github.com/D-Programming-Language/d-programming-language.org/pull/200 struct S { int value; alias this : value; // proposed syntax } Benefits of the proposed syntax are: 2a. It is consistent with class inheritance syntax `class C : B {}`. 2b. It is scalable for multiple alias this feature, as like `alias this : sym1, sym2, ...;` . If D community highly require the syntax `alias this = sym`, I'll agree to adding it again. But for that, we should discuss about its cost and benefit. Sorry for my poor writing. Regards. Kenji Hara
http://forum.dlang.org/thread/aaflopktcjmljxdnoizj forum.dlang.org http://d.puremagic.com/issues/show_bug.cgi?id=9569
Feb 23 2013









"Maxim Fomin" <maxim maxim-fomin.ru> 