Article View: comp.std.c
Article #3587Re: Wishful thinking: return-parameter
From: Paul Long
Date: Tue, 01 Aug 1995 00:22
Date: Tue, 01 Aug 1995 00:22
37 lines
2047 bytes
2047 bytes
halasz@caip.rutgers.edu wrote:
>What with all this stuff propozed for new standard C, one thing I want
>to see, the return-parameter. A function is declared with a set of
>parameters meant to forward to it arugments passd in calling it. The
>declaration for returning looks quite different, and there is no real
>need for "return" to return anithing. Indeed, it were better if it not.
I have not coded in Pascal for almost thirteen years and then for only about a
year, but just about every time I write a function in C that returns a value, I
kinda miss this feature. In C, the idiom is 1. you specify the return type, 2.
you declare an object to hold the return value, 3. you assign a value to the
object, and finally 4. you return the value. Seems kinda redundant. Instead of
this:
NODE *foo(void) {
NODE *result;
...
result = x;
...
return result;
}
You could have this:
NODE *foo(void) result {
result = x;
}
But, having said that, there is an advantage to the idiom besides the
let-C-be-C maxim--it makes explicit that execution of the function is
terminated at this point and that this is the value that is returned. I think
this outweighs the brevity of a "return-parameter."
--
Paul Long 45:29:14N 122:48:09W
plong@perf.com http://www.teleport.com/~pciwww/
"Wagging head and tail, the red-tailed fish, unsupported, turns around."
Technical Details
Message-ID:
<3vjs4c$igf@news0.rain.rg.net>Path:
arc1-ca.pugleaf.net!usenet.eel.ufl.edu!pacifier!rainrgnews0!usenetReferences:
<3ver2u$8bk@caip.rutgers.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!usenet.eel.ufl.edu!pacifier!rainrgnews0!usenet From: Paul Long <plong@perf.com> Newsgroups: comp.std.c Subject: Re: Wishful thinking: return-parameter Date: 1 Aug 1995 00:22:36 GMT Organization: Performance Computing Incorporated Message-ID: <3vjs4c$igf@news0.rain.rg.net> References: <3ver2u$8bk@caip.rutgers.edu> NNTP-Posting-Host: yosemite.perf.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 1.1N (X11; I; SunOS 4.1.1 sun4c) X-URL: news:3ver2u$8bk@caip.rutgers.edu