🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3606

Re: Wishful thinking: return-parameter

#3606
From: Zefram
Date: Wed, 02 Aug 1995 01:52
36 lines
1777 bytes
Markus Freericks <mfx@cs.tu-berlin.de> wrote:
[...]
>[plus an multiple-assignment-statement to match such function results:
>
> int bar; float baz;
> (bar,baz) = foo(42,"test");
>]
[...]
>I have no idea whether this could be introduced painlessly in existing C. I
>guess that the syntax doesn't clash with any existing legal programs, and
>that the semantics doesn't have any problems, either. It might be useful to 
>implicitly declare all return parameters as _register_ (to avoid
>address-taking).

I'm afraid it does.  I think that

int main()
{
 int x = 0, y;
 (x,y) = 3;
 return 0;
}

is a strictly conforming program, having the effect of assigning the
value 3 to y.  Not having a copy of the standard, I'm not absolutely
certain that the result of the comma operator can be an lvalue.  (gcc
groks it, but that's irrelevant.)

Even if that's not a problem for assignments, you have to consider
that, in general, (expression,expression) is a legal expression in C,
which would have a different meaning under your proposal.  I think
allowing aggregate assignments like this is going to be too difficult
to graft onto the language at this stage; we still can't do arbitrary
struct assignments.

-zefram
Technical Details
Message-ID: <1995Aug2.015211.11775@dcs.warwick.ac.uk>
Path: arc1-ca.pugleaf.net!news.dcs.warwick.ac.uk!not-for-mail
References: <3ver2u$8bk@caip.rutgers.edu> <3vhf7k$lo8@mujibur.inmind.com> <DCL2LC.GBK@proteon.com> <3viv5u$bkv@news.cs.tu-berlin.de>

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: <1995Aug2.015211.11775@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> <3vhf7k$lo8@mujibur.inmind.com> <DCL2LC.GBK@proteon.com> <3viv5u$bkv@news.cs.tu-berlin.de>
Date: Wed, 2 Aug 1995 01:52:11 GMT