Topic: this" pointer
Author: kanze@us-es.sel.de (James Kanze US/ESC 60/3/164 #71425)
Date: 20 Sep 1994 16:14:53 GMT Raw View
In article <hpa.13cf0000.Just.say.no.to.DOS@ahab.eecs.nwu.edu>
hpa@ahab.eecs.nwu.edu (H. Peter Anvin) writes:
|> An lvalue is a value you can take the address of.
False. To quote the ARM: "The operand [of operator&] must be a
function, an lvalue, or a qualified-name." So there are things (like
functions) whose address can be taken which are not l-values.
Even without these exceptions, the above is a circular definition: A
lvalue is something whose address can be take, and to take something's
address, it must be an lvalue.
One thing is certain: the definition of lvalue used in the C standard
cannot simply be taken over into C++. It just doesn't work.
--
James Kanze Tel.: (+33) 88 14 49 00 email: kanze@lts.sel.alcatel.de
GABI Software, Sarl., 8 rue des Francs-Bourgeois, F-67000 Strasbourg, France
Conseils en informatique industrielle --
-- Beratung in industrieller Datenverarbeitung
Author: kanze@us-es.sel.de (James Kanze US/ESC 60/3/164 #71425)
Date: 14 Sep 1994 13:57:19 GMT Raw View
In article <rfgCw432B.MGn@netcom.com> rfg@netcom.com (Ronald
F. Guilmette) writes:
|> In article <Cw30u1.LA4@undergrad.math.uwaterloo.ca> cwvernon@undergrad.math.uwaterloo.ca (Vern) writes:
|> >Is the "this" pointer still a valid variable in ANSI C++?
|> Nope.
|> Last I read, it wasn't even an lvalue anymore. So you can't use it as
|> the left operand of an assignment operator (except perhaps an overloaded
|> user-defined one) and you also can't take its address.
I'm not sure whether it is an l-value (or even what lvalue, as opposed
to rvalue, means with regards to C++), but its type is: "T *const" in
the ARM (and I don't think that this has been changed). So you cannot
assign to it.
Even in the earliest versions of C++, it wasn't a variable in the
classical sense of the word, since assigning to it had very special
semantics.
And of course, since it is not of class, you cannot define a user
overload for assignment to it, nor for taking its address.
--
James Kanze Tel.: (+33) 88 14 49 00 email: kanze@lts.sel.alcatel.de
GABI Software, Sarl., 8 rue des Francs-Bourgeois, F-67000 Strasbourg, France
Conseils en informatique industrielle --
-- Beratung in industrieller Datenverarbeitung
Author: rfg@netcom.com (Ronald F. Guilmette)
Date: Wed, 14 Sep 1994 08:46:59 GMT Raw View
In article <Cw30u1.LA4@undergrad.math.uwaterloo.ca> cwvernon@undergrad.math.uwaterloo.ca (Vern) writes:
>Is the "this" pointer still a valid variable in ANSI C++?
Nope.
Last I read, it wasn't even an lvalue anymore. So you can't use it as
the left operand of an assignment operator (except perhaps an overloaded
user-defined one) and you also can't take its address.
--
-- Ron Guilmette, Sunnyvale, CA ---------- RG Consulting -------------------
---- domain addr: rfg@netcom.com ----------- Purveyors of Compiler Test ----
---- uucp addr: ...!uunet!netcom!rfg ------- Suites and Bullet-Proof Shoes -
Author: cwvernon@undergrad.math.uwaterloo.ca (Vern)
Date: Tue, 13 Sep 1994 19:01:12 GMT Raw View
Is the "this" pointer still a valid variable in ANSI C++?
--
Never trouble trouble 'til trouble troubles you.