Article View: comp.std.c
Article #3615Re: Wishful thinking: return-parameter
From: Markus Freericks
Date: Wed, 02 Aug 1995 13:16
Date: Wed, 02 Aug 1995 13:16
28 lines
2000 bytes
2000 bytes
In article <3vl6b2$dne@solutions.solon.com> seebs@solutions.solon.com (Peter Seebach) writes: > >- what if you _want_ one or all results to be undefined? > > Give a real-world example, and I'll worry about it. A function that determines the intersection between two line segments, determined by four float arguments (two points) each, returning an enum flag (no intersection / one point intersection / line segment intersection) and four float results, of which either none, two, or all four are defined. > >- maybe you _want_ to store the result before doing a side effect without > > having to resort to an auxiliary variable, as in > > Yes, but at this point, you're assuming the hardware has some clever trick > for return values. Or you're invoking "invisible overhead", which is > against the spirit of C. Most hardware _has_ a clever trick for return values: registers. Most compilers use a register to pass the return value up, no? On the topic of hidden costs: _current_ C has an "invisible overhead", as the return value is copied to some unnamed location by the returning function, and then read from that location when the calling function uses the value. Introducing one or more explicit return parameters would remove this "hidden variable"! -- Markus (All IMHO, of course ;-)
Technical Details
Message-ID:
<3vnqah$1ev@news.cs.tu-berlin.de>Path:
arc1-ca.pugleaf.net!cs.tu-berlin.de!mfxReferences:
<3ver2u$8bk@caip.rutgers.edu> <3viv5u$bkv@news.cs.tu-berlin.de> <3vjlmk$8co@caip.rutgers.edu> <3vkvmm$rtt@news.cs.tu-berlin.de> <3vl6b2$dne@solutions.solon.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!cs.tu-berlin.de!mfx From: mfx@cs.tu-berlin.de (Markus Freericks) Newsgroups: comp.std.c Subject: Re: Wishful thinking: return-parameter Date: 02 Aug 1995 13:16:12 GMT Organization: TU Berlin Fachbereich Informatik Message-ID: <3vnqah$1ev@news.cs.tu-berlin.de> References: <3ver2u$8bk@caip.rutgers.edu> <3viv5u$bkv@news.cs.tu-berlin.de> <3vjlmk$8co@caip.rutgers.edu> <3vkvmm$rtt@news.cs.tu-berlin.de> <3vl6b2$dne@solutions.solon.com> NNTP-Posting-Host: lenin.cs.tu-berlin.de Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit In-reply-to: seebs@solutions.solon.com's message of 01 Aug 1995 13:22:58 MET