From 4189504279330739455
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,a1bad1ffc4f79f48
X-Google-Attributes: gidf78e5,public
Path: g2news1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!news2.telebyte.nl!fr.ip.ndsoftware.net!proxad.net!proxad.net!194.159.246.34.MISMATCH!kibo.news.demon.net!mutlu.news.demon.net!demon!mail2news.demon.co.uk!devnull
From: llewelly.at@xmission.dot.com (llewelly)
Newsgroups: comp.std.c++
Subject: Re: Idea for calling multiple methods on a single object.
Date: Mon, 7 Jun 2004 16:48:45 +0000 (UTC)
Organization: The Illusory Sorting Algorithm
Lines: 68
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <86hdtncoy2.fsf@Zorthluthik.local.bar>
References: <194c1211.0406060903.6731d4ee@posting.google.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: mail2news.demon.co.uk 1086626925 22307 10.0.0.1 (7 Jun 2004 16:48:45 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Mon, 7 Jun 2004 16:48:45 +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 1BXNIi-0005ne-00
	for mail2news@news.news.demon.net; Mon, 07 Jun 2004 16:48:44 +0000
X-Received: from mulga.cs.mu.OZ.AU (localhost [127.0.0.1]) by mulga.cs.mu.OZ.AU with ESMTP
	id i57GmgB5021289; Tue, 8 Jun 2004 02:48:42 +1000 (EST)
X-Received: (from fjh@localhost)
	by mulga.cs.mu.OZ.AU (8.12.10+Sun/8.12.9/Submit) id i57GmgPs021280;
	Tue, 8 Jun 2004 02:48:42 +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: Mon, 7 Jun 2004 16:29:30 +0000 (UTC)
X-User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3.50 (berkeley-unix)
X-Cancel-Lock: sha1:O2bPT6BCazHvNDswMaa8S+/dpZ8=
X-SA-Exim-Mail-From: news@xmission.com
X-SA-Exim-Version: 3.1 (built Wed Aug 20 09:38:54 PDT 2003)
X-SA-Exim-Scanned: Yes
X-Spam-Checker-Version: SpamAssassin 2.60-mulga_r1 (1.212-2003-09-23-exp) on 
	mulga.cs.mu.OZ.AU
X-Spam-Level: 
X-Spam-Status: No, hits=-3.7 required=5.2 tests=AWL,BAYES_00 autolearn=ham 
	version=2.60-mulga_r1
Xref: g2news1.google.com comp.std.c++:691

bekkah@web.de (Helium) writes:

> Multiple method-call:
>
> At the moment calling more than one method on one object is
> complicated. Imagine you want to call two methods on the (temporary)
> result of a function. How dod you do this? One possibility is to call
> the function twice.
>
> foo ().method1 ();
> foo ().method2 ();
>
> This is a working solution, but calling the function twice could be
> time consuming or even worse, the function could have some side
> effects you only ant to appear once. So this isn't a solution.
>
> Another possible solution is to store the rusult somewhere.
>
> {
>    Type tmp = foo ();
>    tmp.method1 ();
>    tmp.method2 ();
> }
>
>
> This is very unconvenient and the result has to be copied which cvan
> be time consuming as well. And you have to know the function's return
> type. If it's a reference to an object its type isn't know at
> compile-time, so you have to use a reference, too. If it's a temporary
> object you can't store it in a reference but you have to make a copy
> of it. In both cases you have to create an additional temporary
> (weither a reference or a complete object).
>
> I suggest a new synthax to call multiple methods on a single object.
> The notation I propose looks like this:
>
> object.(method_1 (), method_2 (), ..., method_n ());
> pointer->(method_1 (), method_2 (), ..., method_n ());
>
>
> The result is that of the last function. This should feel familiar, as
> a multiple method-call looks similar to calling several functions
> using the operator ,:
>
> (function_1 (), function_2 (), ..., function_n ());
>
>
> 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();

?

---
[ 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                       ]



