Article View: comp.std.c
Article #446Return (errors, multi-items, etc.)
From: Marc W. Mengel
Date: Fri, 11 Aug 1989 18:04
Date: Fri, 11 Aug 1989 18:04
45 lines
1307 bytes
1307 bytes
Several folks have posted discussions of how we ought
to extend C to do things like
{a,b,c} = f(x,y);
or
if( error( y = f(x) ) ) { ... }
There is a very simple pardigm you can use in C for these
sorts of things. Simply using
int
MapxyToabc( x, y, a, b, c )
int x,y,*a,*b,*c;
{
*a=x+y;
*b=x-y;
...
return 1;
}
Then you can have multiple return values via multiple
pointer to result arguments, and a true/false or
0..n error code result that you can use in guarded
statements like
if( f(x,y,&a,&b,&c) ) {...}
In short, why extend the language? We can already
do these things, without changing the language.
Is
{a,b,c} = f(x,y);
really that much prettier than
f(x,y, &a,&b,&c);
???
--
Marc Mengel mmengel@cuuxb.att.com
attmail!mmengel
...!{lll-crg|att}!cuuxb!mmengel
Technical Details
Message-ID:
<2987@cuuxb.ATT.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!iuvax!cica!tut.cis.ohio-state.edu!att!cuuxb!mmengelShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!iuvax!cica!tut.cis.ohio-state.edu!att!cuuxb!mmengel From: mmengel@cuuxb.ATT.COM (Marc W. Mengel) Newsgroups: comp.std.c Subject: Return (errors, multi-items, etc.) Message-ID: <2987@cuuxb.ATT.COM> Date: 11 Aug 89 18:04:18 GMT Reply-To: mmengel@cuuxb.att.com (Marc W. Mengel) Organization: AT&T-DSD, System Engineering for Resellers, Lisle IL Lines: 45