Article View: comp.std.c
Article #3603Re: Wishful thinking: return-parameter
From: Zefram
Date: Tue, 01 Aug 1995 23:42
Date: Tue, 01 Aug 1995 23:42
31 lines
1808 bytes
1808 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.
[...]
>Fortran and Pascal s mistake was to name the return-parameter the same
>as the function, the basic idea is good. This means that we can free
>us of the "goto"ish "return".
I don't think that's such a good idea. the return statement is very
useful, and the best way to structure much code. In languages where
the Pascal method is used, one often sees actual gotos, or very
tortuous logic, in order to jump to the end of the function to return a
value, where a return would make much more sense. In any case, if you
want a return variable, it's easy to implement in C:
int function()
{
int ret; /* This is the return variable */
/* declarations & code ... */
return ret;
}
If there is no other explicit return, then the value of ret when the
end of the function is reached is returned. This is actually a fairly
common usage in C, with it being perfectly normal, and useful, to have
other returns in the code.
-zefram
Technical Details
Message-ID:
<1995Aug1.234258.576@dcs.warwick.ac.uk>Path:
arc1-ca.pugleaf.net!news.dcs.warwick.ac.uk!not-for-mailReferences:
<3ver2u$8bk@caip.rutgers.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!news.dcs.warwick.ac.uk!not-for-mail From: A.Main@dcs.warwick.ac.uk (Zefram) Subject: Re: Wishful thinking: return-parameter X-Nntp-Posting-Host: stone Message-ID: <1995Aug1.234258.576@dcs.warwick.ac.uk> Sender: news@dcs.warwick.ac.uk (Network News) Organization: Department of Computer Science, Warwick University, England References: <3ver2u$8bk@caip.rutgers.edu> Date: Tue, 1 Aug 1995 23:42:58 GMT