Article View: comp.lang.misc
Article #2313Re: Two questions
From: Tom Christiansen
Date: Mon, 05 Oct 1992 02:54
Date: Mon, 05 Oct 1992 02:54
34 lines
2020 bytes
2020 bytes
From the keyboard of sdm@cs.brown.edu (Scott Meyers):
:2. Some languages allow for multiple assignments as part of the same
: statement, where the semantics are that all right-hand sides are
: evaluated before any left-hand sides. To swap x and y, then, you can
: just write this:
:
: x = y, y = x
:
: This is completely deterministic -- it's not the same as saying that
: the two assignments are carried out in parallel.
:
: Anyway, I've forgotten where I read about this construct (I thought it
: was CSP, but I appear to have been mistaken), and I'd like to give a
: citation for one or more languages that use it. Obviously, the
: language that originated the construct would be nice, but I'm not that
: picky. Anybody know what language(s) support this construct?
Perl supports multiple assignments:
($x, $y) = (Peanuts, Pecans);
means
$x = Peanuts;
$y = Pecans;
and also allows you to swap values as you're looking for:
($x, $y) = ($y, $x);
--tom
--
Tom Christiansen tchrist@convex.com convex!tchrist
"We're going to have the best educated Americans in the world!"
--Dan Quayle
Technical Details
Message-ID:
<1992Oct5.025426.22189@news.eng.convex.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!eff!news.oc.com!convex!tchristReferences:
<1992Oct2.164936.20520@cs.brown.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.misc
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!eff!news.oc.com!convex!tchrist
From: Tom Christiansen <tchrist@convex.COM>
Subject: Re: Two questions
Originator: tchrist@pixel.convex.com
Sender: usenet@news.eng.convex.com (news access account)
Message-ID: <1992Oct5.025426.22189@news.eng.convex.com>
Date: Mon, 5 Oct 1992 02:54:26 GMT
Reply-To: tchrist@convex.COM (Tom Christiansen)
References: <1992Oct2.164936.20520@cs.brown.edu>
Nntp-Posting-Host: pixel.convex.com
Organization: Convex Computer Corporation, Colorado Springs, CO
X-Disclaimer: This message was written by a user at CONVEX Computer
Corp. The opinions expressed are those of the user and
not necessarily those of CONVEX.
Lines: 34