December 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 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
December 17, 2004
Lionello Lunesu wrote:

> 
>>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.

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'.

> 
>>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. 
> 

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....
December 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 a

this 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


December 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.html

As "Ric" said it:

 >>Oh well, maybe I'm way too late for such a proposal, but anyway I
tried...

Lionello.


December 17, 2004
In article <cpuu6m$2ds3$1@digitaldaemon.com>, Lionello Lunesu says...
>
>> It's always short. It's always the same.
>
>True, but this doesn't really 'fire' the alternatives.

Okay, but the alternative hasn't even been hired yet, and the status quo already all of his stuff in his office.

>
>> 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)

I prefer "this". "class" is too long. ;)


>> 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.

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.

>As "Ric" said it:
>
> >>Oh well, maybe I'm way too late for such a proposal, but anyway I
>tried...
>
>Lionello.

It doesn't hurt to mention it, but I doubt it's going to change.

jcc7
December 17, 2004
>>>"new" and "delete" are also in use, for allocator/deallocator: http://www.digitalmars.com/d/memory.html#newdelete
>>
>> No need to change this. They just take care of the memory allocation, not the construction of the members.
>
> Just meant that they have less funky names...

Yeah, indeed. They should have been called "mem" and "~mem". It' short, always the same, easy to remember. I'm joking! Djeez.

L.


December 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 conflicts

Ah, but it does! Remember 'this' the pointer?

> - this allows same naming for every class/no retyping when renaming class

This 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.


December 17, 2004
Lionello Lunesu wrote:
>I wrote: 
>>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

 Hehe I will agree for some its not really descriptive.
> 
> 
>>-  PHP uses them??? Python uses __init__, so why not use init() ?
> 
> 
> Agreed, lets add it to the list of alternatives.

That was tongue in cheek! PHP seems an odd animal to mimic for a systems language.

> 
> 
>>- *this  doesnt cause any naming conflicts
> 
> 
> Ah, but it does! Remember 'this' the pointer?
> 
> 
> L. 
> 

I actually like the suggestion you made in the other thread
class() and ~class(), but its too late at this point.


December 18, 2004
Anders F Björklund wrote:
> Lars Ivar Igesund 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.
> 
> 
> Do you have any links to any interesting arguments, pro or contra?

Nah, I like the current naming :) (although I have no really strong opinions on this matter)

Lars Ivar Igesund
December 18, 2004
Lars Ivar Igesund wrote:

>>> 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?
> 
> Nah, I like the current naming :) (although I have no really strong opinions on this matter)

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.
--anders