Path: utzoo!attcan!uunet!samsung!usc!wuarchive!mailrus!news-server.csri.toronto.edu!torsqnt!lethe!geac!alias!fred!rae From: rae@gpu.utcs.toronto.edu (Reid Ellis) Newsgroups: comp.std.c++ Subject: virtually typed return values [WAS: the most dissatisfying part of c++] Message-ID: Date: 1 Aug 90 15:42:12 GMT References: <27634@netnews.upenn.edu> <2314@vela.acs.oakland.edu> Sender: Reid Ellis Reply-To: Reid Ellis Organization: Alias Research, Inc. Toronto ON Canada Lines: 35 schemers@vela.acs.oakland.edu (Roland Schemers III) writes: |I understand your point of view though, and I think it would be nice |if there was some construct in C++ to do what you want. I know some of |my classes could use it. Maybe something like: | |class a { | public: | virtual& test() { | // do some modification to the state of this object, | // then ... | return *this; | } |}; | |In otherwords, make the return type 'virtual' like functions. This is nice in that it uses an already key word. However, this would be too easily mixed up with people just forgetting to put type names in their functions. Rather than just virtual &method(); how about virtual class& method(); instead? "class" is already a keyword and it even sounds like what it is -- a reference to the current "class". But you're right, this sounds like the syntax proposed for templates, so maybe they will solve this problem without this changed syntax. Reid -- Reid Ellis 264 Broadway Avenue, Toronto ON, M4P 1V9 Canada rae@gpu.utcs.toronto.edu || rae%alias@csri.toronto.edu || +1 416 487 1383