digitalmars.D - Rename ctor / dtor
- Lionello Lunesu (31/31) Dec 17 2004 Hi..
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (24/47) Dec 17 2004 I think you mean constTractor and deathTractor, the new names :)
- Lionello Lunesu (24/47) Dec 17 2004 Ah, summing it all up: I think "construct" and "destruct" are the best
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (9/29) Dec 17 2004 PHP adds __ to all system functions,
- Lionello Lunesu (3/9) Dec 17 2004 Yeah, indeed. They should have been called "mem" and "~mem". It' short,
- Lars Ivar Igesund (4/7) Dec 17 2004 Somewhat late as the discussion has been had before. No changes were
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (7/18) Dec 17 2004 Do you have any links to any interesting arguments, pro or contra?
- Ivan Senji (8/26) Dec 17 2004 1. I always liked "this" too! :)
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (6/11) Dec 17 2004 The tricky one is "~this", but that exception could be learned I guess ?
- David Medlock (6/35) Dec 17 2004 I also think this() and ~this() are clean, and unabiguous.
- Lionello Lunesu (16/21) Dec 17 2004 How can you say it's unambiguous when 'this' is both the constructor met...
- David Medlock (19/44) Dec 17 2004 Adding more keywords adds the the number of things I must keep in my
- Lionello Lunesu (20/38) Dec 17 2004 Hey, but that's another point! I was reacting to the "works with C++ syn...
- David Medlock (6/37) Dec 17 2004 That was tongue in cheek! PHP seems an odd animal to mimic for a systems...
- Lionello Lunesu (11/17) Dec 18 2004 They're still just english words, but PHP just proves that it kind-a mak...
- Lars Ivar Igesund (4/16) Dec 18 2004 Nah, I like the current naming :) (although I have no really strong
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (7/14) Dec 18 2004 Okay, so people wanted the naming to change before - and it didn't...
- Lars Ivar Igesund (7/22) Dec 18 2004 Well, people don't necessarily mean 'all'. I don't think enough people
- =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= (3/8) Dec 18 2004 Fair enough... And there are enough other issues to address, I suppose.
- J C Calvarese (8/15) Dec 17 2004 It's always short. It's always the same. It's a keyword, but it's not an
- Lionello Lunesu (9/16) Dec 17 2004 I regard that as a bad thing. Agreed, 'this' as constructor has somethin...
- J C Calvarese (15/29) Dec 17 2004 Okay, but the alternative hasn't even been hired yet, and the status quo...
- Ant (10/13) Dec 17 2004 this come up before.
Hi.. <preamble> How is D's this(...) and ~this(...) for the constructor and destructor for a class an improvement over C++ / Java's classname(...) / ~classname(...) ? I guess renaming a class just got easier. But is this worth introducing a completely new meaning for an existing keyword, 'this'? (note: I regard changing 'this' to be the actual instance instead of a pointer to it not a 'completely new meaning') Come to think of it, when creating a new instance of a class "new Car(...)", it's more obvious that the class' function Car(...) gets called than this(...). Also, it's impossible to store a pointer (delegate) to a class' constructor for later reinitialisation, because "&this" won't work (I don't know if this is actually possible, but it would sure eliminate Init() methods in many of my classes). The only special thing about the constructor and destructor is that they implicitly construct/destruct the class' members and inherited classes. They are just methods. </preamble> <suggestion> Would changing the names to "constructor" and "destructor" (or "ctor" and "dtor", or "construct" / "destruct") not make more sense? </suggestion> I guess this would lower the threshold for new programmers to use D even more. I hope I don't get only "too late to make such a rigorous change" ractions :-/ (It seems I guess I hope and I think a lot :-S) (A Python PEP-like system would be very nice for D. All these loose suggestions that get lost in the newsgroup after some time is a real pity. Another suggestion.) -- Lionello. -- Get the root certificate at https://www.cacert.org/
Dec 17 2004
Lionello Lunesu wrote:How is D's this(...) and ~this(...) for the constructor and destructor for a class an improvement over C++ / Java's classname(...) / ~classname(...) ?[...]Would changing the names to "constructor" and "destructor" (or "ctor" and "dtor", or "construct" / "destruct") not make more sense?I think you mean constTractor and deathTractor, the new names :) Seriously, I don't think "construct" and "destruct" looks bad... Look at what PHP 5 uses, for instance: http://talks.php.net/show/php5_ca/3 "new" and "delete" are also in use, for allocator/deallocator: http://www.digitalmars.com/d/memory.html#newdelete The current name, "this", reflects to how it is being called from another constructor, which works the same as in Java :class C { int j; this() { ... } this(int i) { this(); j = i; } }So if you changed the names, *that* call would look more obscure... ? (since destructors aren't called explicitly, their name matters less) Not that it would be *very* strange to instead call eg. "construct()".I guess this would lower the threshold for new programmers to use D even more. I hope I don't get only "too late to make such a rigorous change" ractions :-/ (It seems I guess I hope and I think a lot :-S)"this" and "~this" are somewhat obscure names, that much is true... The only improvement over C++ / Java is not requiring the class name, at the expense of losing "instant recognition" for those used to them... For newcomers, "construct" and "destruct" are probably easier to grasp ?(A Python PEP-like system would be very nice for D. All these loose suggestions that get lost in the newsgroup after some time is a real pity. Another suggestion.)A list of bugs would be nice too... (like Bugzilla or so) But for now, there are just: http://www.prowiki.org/wiki4d/wiki.cgi?PendingPeeves http://www.prowiki.org/wiki4d/wiki.cgi?FeatureRequestList Currently most of them are just piling up, for either Walter (DMD) or David (GDC), to take a look at when they're able... --anders
Dec 17 2004
Hi,Ah, summing it all up: I think "construct" and "destruct" are the best options too, because... * they're actual english words (as opposed to ctor/dtor); * they actually describe what's going on; * PHP5 uses them too (be it with "__", which I'd drop); * they don't cause any conflicts (within D itself that is).Would changing the names to "constructor" and "destructor" (or "ctor" and "dtor", or "construct" / "destruct") not make more sense?Seriously, I don't think "construct" and "destruct" looks bad... Look at what PHP 5 uses, for instance: http://talks.php.net/show/php5_ca/3"new" and "delete" are also in use, for allocator/deallocator: http://www.digitalmars.com/d/memory.html#newdeleteNo need to change this. They just take care of the memory allocation, not the construction of the members.The current name, "this", reflects to how it is being called from another constructor, which works the same as in Java :So "this()" in java calls "classname()" ? :-SSo if you changed the names, *that* call would look more obscure... ? (since destructors aren't called explicitly, their name matters less) Not that it would be *very* strange to instead call eg. "construct()".Right, I'd prefer if the constructor and destructor get treated as normal methods as much as possible. Why change the name? (Ah, because calling another constructor does NOT re-construct the members?)"this" and "~this" are somewhat obscure names, that much is true...Yeah, I've been programming C/C++ for 8 years now, and I just figured out LAST WEEK that "~class()" could be read as "not class()" :-S By hackers, for hackers.The only improvement over C++ / Java is not requiring the class name, at the expense of losing "instant recognition" for those used to them...Agreed. So the constructor and destructor should have a fixed name in any class.For newcomers, "construct" and "destruct" are probably easier to grasp ?For sure they're easier to grasp than this and ~this.. Hey, even !this would be easier to grasp :-)A wiki is not really suitable for this kind of thing becuase of the variable layout. But maybe I'll just update that feature request list. So it doesn't get lost :-/ Lionello.(A Python PEP-like system would be very nice for D. All these loose suggestions that get lost in the newsgroup after some time is a real pity. Another suggestion.)A list of bugs would be nice too... (like Bugzilla or so) But for now, there are just: http://www.prowiki.org/wiki4d/wiki.cgi?PendingPeeves http://www.prowiki.org/wiki4d/wiki.cgi?FeatureRequestList
Dec 17 2004
Lionello Lunesu wrote:Ah, summing it all up: I think "construct" and "destruct" are the best options too, because... * they're actual english words (as opposed to ctor/dtor); * they actually describe what's going on; * PHP5 uses them too (be it with "__", which I'd drop); * they don't cause any conflicts (within D itself that is).PHP adds __ to all system functions, to avoid clashing with legacy names.Just meant that they have less funky names..."new" and "delete" are also in use, for allocator/deallocator: http://www.digitalmars.com/d/memory.html#newdeleteNo need to change this. They just take care of the memory allocation, not the construction of the members.Indeed it does. (and super() calls the parent) In java, the constructor call must be first. (before *any* other code in the constructor)The current name, "this", reflects to how it is being called from another constructor, which works the same as in Java :So "this()" in java calls "classname()" ? :-SA wiki is not really suitable for this kind of thing becuase of the variable layout. But maybe I'll just update that feature request list. So it doesn't get lost :-/I'd chalk it up to "better than nothing"... --anders
Dec 17 2004
Yeah, indeed. They should have been called "mem" and "~mem". It' short, always the same, easy to remember. I'm joking! Djeez. L.Just meant that they have less funky names..."new" and "delete" are also in use, for allocator/deallocator: http://www.digitalmars.com/d/memory.html#newdeleteNo need to change this. They just take care of the memory allocation, not the construction of the members.
Dec 17 2004
Lionello Lunesu wrote:I guess this would lower the threshold for new programmers to use D even more. I hope I don't get only "too late to make such a rigorous change" ractions :-/ (It seems I guess I hope and I think a lot :-S)Somewhat late as the discussion has been had before. No changes were made then. Lars Ivar Igesund
Dec 17 2004
Lars Ivar Igesund wrote:Do you have any links to any interesting arguments, pro or contra? All I could find was:I guess this would lower the threshold for new programmers to use D even more. I hope I don't get only "too late to make such a rigorous change" ractions :-/ (It seems I guess I hope and I think a lot :-S)Somewhat late as the discussion has been had before. No changes were made then.I like 'this' it made sense as soon as I heard it. It's certainly better than typing the class name. 'constructor' is too long. 'ctor' only makes sense if you have heard that term used before.(From http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/7701) Which the names "construct" and "destruct" would fix, IMHO. A little interesting to claim legacy reasons, for a unreleased language? --anders
Dec 17 2004
"Anders F Björklund" <afb algonet.se> wrote in message news:cpuhd6$1v3e$1 digitaldaemon.com...Lars Ivar Igesund wrote:1. I always liked "this" too! :) 2. If "this" is a reference to the object, doesn't it make sense that the method that creates the object is also "this"? 3. It is short. 4. It isn't hard to learn or remember.Do you have any links to any interesting arguments, pro or contra? All I could find was:I guess this would lower the threshold for new programmers to use D even more. I hope I don't get only "too late to make such a rigorous change" ractions :-/ (It seems I guess I hope and I think a lot :-S)Somewhat late as the discussion has been had before. No changes were made then.I like 'this' it made sense as soon as I heard it.It's certainly better than typing the class name. 'constructor' is too long. 'ctor' only makes sense if you have heard that term used before.(From http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/7701) Which the names "construct" and "destruct" would fix, IMHO. A little interesting to claim legacy reasons, for a unreleased language? --anders
Dec 17 2004
Ivan Senji wrote:1. I always liked "this" too! :) 2. If "this" is a reference to the object, doesn't it make sense that the method that creates the object is also "this"? 3. It is short.I think in nested constructors make sense, not sure about the otherwise.4. It isn't hard to learn or remember.The tricky one is "~this", but that exception could be learned I guess ? It's not like it's going to change, anyway ? ;-) (but if it was, my vote is on: "this"->"construct", "~this"->"destruct") --anders
Dec 17 2004
I also think this() and ~this() are clean, and unabiguous. They are also very easy to find when reading through source because this is highlighted even for C++ highlighting. Obviously ctor could be highlighted, but I really don't see an advantage over just using the existing keyword rather than adding another.... Ivan Senji wrote:"Anders F Björklund" <afb algonet.se> wrote in message news:cpuhd6$1v3e$1 digitaldaemon.com...Lars Ivar Igesund wrote:1. I always liked "this" too! :) 2. If "this" is a reference to the object, doesn't it make sense that the method that creates the object is also "this"? 3. It is short. 4. It isn't hard to learn or remember.Do you have any links to any interesting arguments, pro or contra? All I could find was:I guess this would lower the threshold for new programmers to use D even more. I hope I don't get only "too late to make such a rigorous change" ractions :-/ (It seems I guess I hope and I think a lot :-S)Somewhat late as the discussion has been had before. No changes were made then.I like 'this' it made sense as soon as I heard it.
Dec 17 2004
I also think this() and ~this() are clean, and unabiguous.How can you say it's unambiguous when 'this' is both the constructor method and a pointer to the object? ~this is both the destructor and 'the binary negation of the value of the pointer to the object' (OK, I exagerated, a little)...They are also very easy to find when reading through source because this is highlighted even for C++ highlighting.True, but hardly an argument worth considering.Obviously ctor could be highlighted, but I really don't see an advantage over just using the existing keyword rather than adding another....[copy_paste] * they're actual english words (as opposed to ctor/dtor); * they actually describe what's going on; * PHP5 uses them too (be it with "__", which I'd drop); * they don't cause any conflicts (within D itself that is); * same naming for every class. Compare with against arguments * 'this' highlights in C++ editors; * same naming for every class; *... uh....more? please add. Lionello.
Dec 17 2004
Lionello Lunesu wrote:Adding more keywords adds the the number of things I must keep in my head in addition to the program I am working on. Every bit of baggage added on increases complexity, and pushes you towards the bucket of trash that is C++. If you disagree fine, but I don't think my point is 'hardly worth considering'.They are also very easy to find when reading through source because this is highlighted even for C++ highlighting.True, but hardly an argument worth considering.In your arguments for using constructor I can apply most of them to *this* also: - *this* is an english word, and its shorter than constructor and destructor. - this() describes construction (imo) - PHP uses them??? Python uses __init__, so why not use init() ? - *this doesnt cause any naming conflicts - this allows same naming for every class/no retyping when renaming class I still do not see how this and ~this are not readable. I learned them both as soon as I read the spec. Yes Walter *could* change the syntax, but I still don't see *why* he should. If its not broken....Obviously ctor could be highlighted, but I really don't see an advantage over just using the existing keyword rather than adding another....[copy_paste] * they're actual english words (as opposed to ctor/dtor); * they actually describe what's going on; * PHP5 uses them too (be it with "__", which I'd drop); * they don't cause any conflicts (within D itself that is); * same naming for every class. Compare with against arguments * 'this' highlights in C++ editors; * same naming for every class; *... uh....more? please add. Lionello.
Dec 17 2004
Adding more keywords adds the the number of things I must keep in my head in addition to the program I am working on. Every bit of baggage added on increases complexity, and pushes you towards the bucket of trash that is C++. If you disagree fine, but I don't think my point is 'hardly worth considering'.Hey, but that's another point! I was reacting to the "works with C++ syntax highlighting"-point. As for the "number of words"-point, that's actually a valid point! Not much I can say. Add it to the list, I suppose. But IMO (Did you see? The H's get dropped as the discussion intensifies) keeping track of two meanings of one word is more difficult than having two different words for the different meanings. Actually three different words (this/construct*/destruct*), against two (this/this/~this).In your arguments for using constructor I can apply most of them to *this* also: - *this* is an english word, and its shorter than constructor and destructor.That's 2 valid points- this() describes construction (imo):-S I'd like to see a vote on this one- PHP uses them??? Python uses __init__, so why not use init() ?Agreed, lets add it to the list of alternatives.- *this doesnt cause any naming conflictsAh, but it does! Remember 'this' the pointer?- this allows same naming for every class/no retyping when renaming classThis one is definately important and should apply to any alternative too.I still do not see how this and ~this are not readable. I learned them both as soon as I read the spec. Yes Walter *could* change the syntax, but I still don't see *why* he should. If its not broken....I hate that line... :-( Also it keeps people from refactoring their code 'cause "it works, right?".. In the software product I'm currently working on, this reasoning caused too many problems. (Hmm, voting with a wiki, everybody add 1, and only 1, to the number of votes for your favorite alternative :-S) L.
Dec 17 2004
Lionello Lunesu wrote:I wrote:Hehe I will agree for some its not really descriptive.In your arguments for using constructor I can apply most of them to *this* also: - *this* is an english word, and its shorter than constructor and destructor.That's 2 valid points- this() describes construction (imo):-S I'd like to see a vote on this oneThat was tongue in cheek! PHP seems an odd animal to mimic for a systems language.- PHP uses them??? Python uses __init__, so why not use init() ?Agreed, lets add it to the list of alternatives.I actually like the suggestion you made in the other thread class() and ~class(), but its too late at this point.- *this doesnt cause any naming conflictsAh, but it does! Remember 'this' the pointer? L.
Dec 17 2004
Yo,They're still just english words, but PHP just proves that it kind-a makes sense to call the constructor and destructor 'construct' and 'destruct'. Not really mimicing a PHP language feature..That was tongue in cheek! PHP seems an odd animal to mimic for a systems language.- PHP uses them??? Python uses __init__, so why not use init() ?Agreed, lets add it to the list of alternatives.I actually like the suggestion you made in the other thread class() and ~class(), but its too late at this point.Yeah, I guess that's really the only thing "this" and "~this" have going for them: it was decided, so live with it :-S I had another reason though why "this" is a strange name for the constructor. One pro was that "this" had something to do with the creation of the object (be it vaguely). But for "static this", the static constructor, it doesn't make any sense, since there's no 'this' being initialised. Lionello.
Dec 18 2004
Anders F Björklund wrote:Lars Ivar Igesund wrote:Nah, I like the current naming :) (although I have no really strong opinions on this matter) Lars Ivar IgesundDo you have any links to any interesting arguments, pro or contra?I guess this would lower the threshold for new programmers to use D even more. I hope I don't get only "too late to make such a rigorous change" ractions :-/ (It seems I guess I hope and I think a lot :-S)Somewhat late as the discussion has been had before. No changes were made then.
Dec 18 2004
Lars Ivar Igesund wrote:Okay, so people wanted the naming to change before - and it didn't... And because it was left as it is then, that's the way it's gonna be ? I can live with "this" and "not this", just thought the new names "construct" and "destruct" were more self-explanatory than they are ? Maybe for 2.0 then. --andersNah, I like the current naming :) (although I have no really strong opinions on this matter)Somewhat late as the discussion has been had before. No changes were made then.Do you have any links to any interesting arguments, pro or contra?
Dec 18 2004
Anders F Björklund wrote:Lars Ivar Igesund wrote:Well, people don't necessarily mean 'all'. I don't think enough people could agree on an better alternative. The fact that possibly most people on the NG might believe that there are better alternatives, don't mean that such an alternative got a major number of votes when measured up against no real need for change. Lars Ivar IgesundOkay, so people wanted the naming to change before - and it didn't... And because it was left as it is then, that's the way it's gonna be ?Nah, I like the current naming :) (although I have no really strong opinions on this matter)Somewhat late as the discussion has been had before. No changes were made then.Do you have any links to any interesting arguments, pro or contra?
Dec 18 2004
Lars Ivar Igesund wrote:Well, people don't necessarily mean 'all'. I don't think enough people could agree on an better alternative. The fact that possibly most people on the NG might believe that there are better alternatives, don't mean that such an alternative got a major number of votes when measured up against no real need for change.Fair enough... And there are enough other issues to address, I suppose. --anders
Dec 18 2004
In article <cpu62e$1i7f$1 digitaldaemon.com>, Lionello Lunesu says...Hi.. <preamble> How is D's this(...) and ~this(...) for the constructor and destructor for a class an improvement over C++ / Java's classname(...) / ~classname(...) ?It's always short. It's always the same. It's a keyword, but it's not an additional keyword. ..Would changing the names to "constructor" and "destructor" (or "ctor" and "dtor", or "construct" / "destruct") not make more sense? </suggestion>This has been suggested before. I think it's much too late to change it now. http://www.digitalmars.com/d/archives/637.html http://www.digitalmars.com/d/archives/14847.html jcc7
Dec 17 2004
It's always short. It's always the same.True, but this doesn't really 'fire' the alternatives.It's a keyword, but it's not an additional keyword.I regard that as a bad thing. Agreed, 'this' as constructor has something to do with the other meaning of 'this'. But why not call it "class()" and "~class()" instead? Still short, still the same, no real conflict (since you can't evaluate "class" the way you can evaluate both this'es)This has been suggested before. I think it's much too late to change it now.So D's fixed the way it is? I'm actually asking.http://www.digitalmars.com/d/archives/637.html http://www.digitalmars.com/d/archives/14847.htmlAs "Ric" said it:tried... Lionello.Oh well, maybe I'm way too late for such a proposal, but anyway I
Dec 17 2004
In article <cpuu6m$2ds3$1 digitaldaemon.com>, Lionello Lunesu says...Okay, but the alternative hasn't even been hired yet, and the status quo already all of his stuff in his office.It's always short. It's always the same.True, but this doesn't really 'fire' the alternatives.I prefer "this". "class" is too long. ;)It's a keyword, but it's not an additional keyword.I regard that as a bad thing. Agreed, 'this' as constructor has something to do with the other meaning of 'this'. But why not call it "class()" and "~class()" instead? Still short, still the same, no real conflict (since you can't evaluate "class" the way you can evaluate both this'es)Only Walter knows. ;) I think it mostly is set in stone. I was under the impression that once he gets the bugs out, Walter is going to stamp 1.00 on it. Hopefully, that'll be soon. It's not a good time to be "fixing" what isn't "broken". Maybe it's just me, but this and ~this doesn't seem that hard to remember or understand. (Of course, I'm the one who was trying to use apostrophes to comment out code yesterday, so maybe I shouldn't be voicing my opinion. Oops.) Also, I'm sure Walter has seen suggestions about this before. So I think if he was going to change it, he would have done so last year.This has been suggested before. I think it's much too late to change it now.So D's fixed the way it is? I'm actually asking.As "Ric" said it:It doesn't hurt to mention it, but I doubt it's going to change. jcc7tried... Lionello.Oh well, maybe I'm way too late for such a proposal, but anyway I
Dec 17 2004
In article <cpu62e$1i7f$1 digitaldaemon.com>, Lionello Lunesu says...Hi.. <preamble> How is D's this(...) and ~this(...) for the constructor and destructor for athis come up before. I fully support it. Walter completly ignores it. this() and ~this and ctor and dtor make absolutly no sence. my last argument after exausting all valid ones that are surfacing again (I'm not sure I made this public) is that the parser on phobos calls this() "ctor" and ~this() "dtor". but we are talking to a wall. Ant
Dec 17 2004