[net.lang.c] Multiple assignments

franka@mmintl.UUCP (Frank Adams) (05/12/86)

In article <797@bentley.UUCP> kwh@bentley.UUCP writes:
>In article <501@brl-smoke.ARPA> rbj@icst-cmr (Root Boy Jim) writes:
>>And as someone pointed out, assignments return a value too, so should we
>>cast them to void as well?  Oh yeah, assignment is `different'.
>
>Actually, this does bother me somewhat.  I think I prefer the idea that
>values should be used or explicitly discarded, as in forth.  (Not that forth
>has any error checking!)  No, I'm not suggesting that lint should complain
>about assignments, or that C should have a different notation for assignments
>that are being pipelined into another expression.  Just waiting for the next
>generation of languages.

This bothers me somewhat too.  I do have a suggestion for how to deal with
it: have a "multi-assignment" operator.  Supposing that "$" is being used
for this operator, then to set both "a" and "b" to zero, one would write
"a $ b = 0", rather than "a = b = 0", as C does.  This has the disadvantage
that it cannot be used where the result of the assignment is used
immediately in a calculation (e.g., "a = 2 * b = sqrt(c)").  On the other
hand, if your language supports argument passing by address, it permits an
output argument to be multiply assigned; something which
assignment-with-value does not support.

I am not recommending that this be put into C.  It is an idea for new
languages.  Accordingly, I have directed follow-ups to net.lang instead of
net.lang.c.

Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Multimate International    52 Oakland Ave North    E. Hartford, CT 06108