Path: 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


	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