Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!gem.mps.ohio-state.edu!tut.cis.ohio-state.edu!snorkelwacker!bloom-beacon!eru!luth!sunic!mcsun!ukc!dcl-cs!aber-cs!pcg From: pcg@aber-cs.UUCP (Piercarlo Grandi) Newsgroups: comp.lang.c++ Subject: Re: C++ 2.0 Question -- Whats wrong with this code ?? Summary: Actually this could now be a reference... Message-ID: <1152@aber-cs.UUCP> Date: 20 Oct 89 12:26:06 GMT Reply-To: pcg@cs.aber.ac.uk (Piercarlo Grandi) Organization: Dept of CS, UCW Aberystwyth (Disclaimer: my statements are purely personal) Lines: 36 In article <1532@tukki.jyu.fi> sakkinen@jytko.jyu.fi (Markku Sakkinen) SAKKINEN@FINJYU.bitnet (alternative) writes: [ ... ] According to the reference manual, 'this' is a _constant_ pointer (to the current class object) in Release 2.0, which it wasn't in previous releases. [...] Assignment to 'this' in constructors and destructors for the purpose of programmer-controlled memory allocation and deallocation was a badly structured hack to start with. In Release 2.0 it has been replaced by the possibility to redefine the operators 'new' and 'delete', which is much better and cleaner. [ ... ] It has occurred to me that if BS had hit upon the idea of having overloadable 'new' and 'delete' earlier, instead of the assign-to-this-in-constructor hack, 'this' should have been a reference. Now it is a constant pointer, which is nearly the same, except for the use of '->' instead of '.' to access members. I have been thinking also that if 'this' were made a reference, then it would be possible to dispense with the concept of member procedure entirely; any 'friend' of a class with a first parameter of type reference to that class could be invoked indifferently as a_friend(obj,arg1,arg2) or obj.a_friend(arg1,arg) etcetera, which is similar to what is possible in POP-II. Naturally it would be possible to allow the latter syntax also for non friends, but I opine that it ought to be reserved only to friends. -- Piercarlo "Peter" Grandi | ARPA: pcg%cs.aber.ac.uk@nsfnet-relay.ac.uk Dept of CS, UCW Aberystwyth | UUCP: ...!mcvax!ukc!aber-cs!pcg Penglais, Aberystwyth SY23 3BZ, UK | INET: pcg@cs.aber.ac.uk