this

F

Fraser Ross

How difficult would it be to add a keyword such as thisref to use as an
alternative to this? Or alternatively this could be renamed thisptr and the
keyword this becomes a reference type. It does not look difficult to
introduce.

Fraser.
 
J

JKop

Fraser Ross posted:
How difficult would it be to add a keyword such as thisref to use as an
alternative to this? Or alternatively this could be renamed thisptr
and the keyword this becomes a reference type. It does not look
difficult to introduce.

Fraser.

Well, the dye has already been cast. We can't just get rid of "this" and
render good code bad. Unless... with each copy of the Standard, a new
program is released that will convert CPP files, eg. this will become
thisptr.

I myself would have prefered:

this as a reference

&this as a pointer

or maybe even:

pThis or p_this as a pointer.


Now that that's out of the question, thisref would be a good idea. The thing
is would anyone be bothered at this stage!

-JKop
 
I

Ioannis Vranos

Roman said:
.... one can achieve the same results with both. Just different operators.

Do you prefer '->' before '.' ? Because you will type one character less ?

Can somebody explain to me why reference is considered to be _better_ than
pointer ? Is that because one can overload operator '.' and not '->' ? Or
something else ?



Who said it is better? Everything *depends* on context of use. The
difference between references and pointers is that references do not
have an address of their own and we can not assume that they occupy
space since in many cases they are optimised out by the compiler completely.






Regards,

Ioannis Vranos
 
I

Ioannis Vranos

JKop said:
Fraser Ross posted:




Well, the dye has already been cast. We can't just get rid of "this" and
render good code bad. Unless... with each copy of the Standard, a new
program is released that will convert CPP files, eg. this will become
thisptr.

I myself would have prefered:

this as a reference

&this as a pointer

or maybe even:

pThis or p_this as a pointer.


Now that that's out of the question, thisref would be a good idea. The thing
is would anyone be bothered at this stage!


The general approach of the Standard's committee is to be as
conservative as possible introducing only badly needed features. And
this is not a badly needed feature.






Regards,

Ioannis Vranos
 
M

Markus Dehmann

JKop said:
Why the hell did they make "this" a pointer and not a reference?!! It's so
stupid!

-JKop

Define this:
#define this_ref (*this)

Now you can use this_ref.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,171
Messages
2,570,935
Members
47,472
Latest member
KarissaBor

Latest Threads

Top