From 1289294228464552931
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,a1bad1ffc4f79f48
X-Google-Attributes: gidf78e5,public
Path: g2news1.google.com!news1.google.com!news.glorb.com!newsrout1.ntli.net!news-in.ntli.net!kibo.news.demon.net!mutlu.news.demon.net!demon!mail2news.demon.co.uk!devnull
From: dietmar_kuehl@yahoo.com (Dietmar Kuehl)
Newsgroups: comp.std.c++
Subject: Re: Idea for calling multiple methods on a single object.
Date: Tue, 8 Jun 2004 17:58:42 +0000 (UTC)
Organization: http://groups.google.com
Lines: 43
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <5b15f8fd.0406080032.672c88c9@posting.google.com>
References: <194c1211.0406060903.6731d4ee@posting.google.com> <86hdtncoy2.fsf@Zorthluthik.local.bar>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: mail2news.demon.co.uk 1086717522 10558 10.0.0.1 (8 Jun 2004 17:58:42 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Tue, 8 Jun 2004 17:58:42 +0000 (UTC)
X-Received: from mulga.cs.mu.oz.au ([128.250.1.22])
	by news.demon.co.uk with esmtp (Exim 4.12)
	id 1BXkrx-0002k9-00
	for mail2news@news.news.demon.net; Tue, 08 Jun 2004 17:58:41 +0000
X-Received: from mulga.cs.mu.OZ.AU (localhost [127.0.0.1]) by mulga.cs.mu.OZ.AU with ESMTP
	id i58HwdB5000231; Wed, 9 Jun 2004 03:58:39 +1000 (EST)
X-Received: (from fjh@localhost)
	by mulga.cs.mu.OZ.AU (8.12.10+Sun/8.12.9/Submit) id i58HwcN6000216;
	Wed, 9 Jun 2004 03:58:38 +1000 (EST)
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Path: comp-std-cpp-robomod!not-for-mail
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Delivered-To: std-c++@ucar.edu
X-Newsgroups: comp.std.c++
X-NNTP-Posting-Date: Tue, 8 Jun 2004 08:32:41 +0000 (UTC)
X-Spamscanner: mailbox9.ucsd.edu  (v1.4 May 20 2004 13:55:33, 1.2/5.0 2.63)
X-MailScanner: PASSED (v1.2.8 24335 i588Wg4V043294 mailbox9.ucsd.edu)
X-Spam-Checker-Version: SpamAssassin 2.60-mulga_r1 (1.212-2003-09-23-exp) on 
	mulga.cs.mu.OZ.AU
X-Spam-Status: No, hits=-3.0 required=5.2 tests=AWL,BAYES_00,
	FORGED_YAHOO_RCVD autolearn=no version=2.60-mulga_r1
Xref: g2news1.google.com comp.std.c++:702

llewelly.at@xmission.dot.com (llewelly) wrote:
> bekkah@web.de (Helium) writes:
> > This way the problem I showed above could easiely be solved like this:
> >
> > foo ().(
> >    method1 (), 
> >    method2 ()
> > );
> 
> How is this better than using a reference:
> 
> Type& r= foo();
> r.method1();
> r.method2();

Are you proposing to change the language rules such that binding a
temporary to a non-const reference is allowed? Otherwise I would
claim that Helium's approach works while yours does not...

Nitpicking aside, I don't think that there is any real need for a
language extension allowing only multiple calls for two reasons:
- I think it is rarely necessary to call multiple functions on a
  single object.
- Where it is, a [n inline] function taking the parameter by value
  should do the right thing and is not that much harder to write.

I would rather change the rules for reference handling, possibly
introducing a kind of rvalue reference which accepts binding to
temporaries in addition to what a non-const reference can be bound
to. This would also handle the multiple calls issue: I don't buy
the inconvenience argument but there is an issue with copying. The
issue about needing to know the return type is likely to go away
with whatever approach comes out of the "typeof" discussion.
-- 
<mailto:dietmar_kuehl@yahoo.com> <http://www.dietmar-kuehl.de/>
<http://www.contendix.com> - Software Development & Consulting

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]



