Article View: comp.std.c
Article #3633Re: Wishful thinking: return-parameter
From: Stephen Baynes
Date: Thu, 03 Aug 1995 07:27
Date: Thu, 03 Aug 1995 07:27
46 lines
1685 bytes
1685 bytes
Zefram (A.Main@dcs.warwick.ac.uk) wrote:
: <halasz@caip.rutgers.edu> wrote:
: >No, we are _obliged_ to uze a "goto"ish means for quitting the
: >function,
: If the current return keyword is banned, there will be a great deal
: more use of actual gotos, just to get to the end of a function in order
: to return. I can see code currently like
: int fn()
: {
: int ret;
: if(some_error_condition()) return -1;
: /* ... */
: return ret;
: }
: turning into
: int fn() ret
: {
: if(some_error_condition()) { ret=-1; goto end; }
: /* ... */
: end:
: }
How about using the 'else' keyword:
int fn() ret
{
if(some_error_condition()) {
ret=-1;
}else{
/* ... */
}
}
It is a much better way to do it anyway even in current C as it makes
maitenace simpler (consider adding code to end of function to be done
on all returns).
--
Stephen Baynes baynes@mulsoc2.serigate.philips.nl
Philips Semiconductors Ltd
Southampton My views are my own.
United Kingdom
Technical Details
Message-ID:
<DCq4py.Mpq@ukpsshp1.serigate.philips.nl>Path:
arc1-ca.pugleaf.net!phcoms4.seri.philips.nl!panther!baynesReferences:
<3ver2u$8bk@caip.rutgers.edu> <3vg8l8$5sd@myst.plaza.ds.adp.com> <DCL2LC.GBK@proteon.com> <3vjjl6$7nm@caip.rutgers.edu> <1995Aug2.080237.17479@dcs.warwick.ac.uk>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!phcoms4.seri.philips.nl!panther!baynes From: baynes@ukpsshp1.serigate.philips.nl (Stephen Baynes) Subject: Re: Wishful thinking: return-parameter Sender: news@ukpsshp1.serigate.philips.nl (account for localnews) Message-ID: <DCq4py.Mpq@ukpsshp1.serigate.philips.nl> Date: Thu, 3 Aug 1995 07:27:34 GMT References: <3ver2u$8bk@caip.rutgers.edu> <3vg8l8$5sd@myst.plaza.ds.adp.com> <DCL2LC.GBK@proteon.com> <3vjjl6$7nm@caip.rutgers.edu> <1995Aug2.080237.17479@dcs.warwick.ac.uk> Organization: Philips Semiconductors, Southampton, UK X-Newsreader: TIN [version 1.2 PL2]