Thread View: comp.lang.misc
3 messages
3 total messages
Started by Scott Meyers
Fri, 02 Oct 1992 16:49
Two questions
Author: Scott Meyers
Date: Fri, 02 Oct 1992 16:49
Date: Fri, 02 Oct 1992 16:49
40 lines
1752 bytes
1752 bytes
Two questions about miscellaneous languages:
1. Regarding the language occam, I have this sample program fragment:
WHILE TRUE
SEQ
PAR
south ! x
east ? sum
temp := a * x
PAR
west ! sum + temp
north ? x
All I really need to know is this: is the language case-sensitive? In
particular, can "PAR" above be also written "Par", "par", etc?
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?
Thanks,
Scott
-------------------------------------------------------------------------------
What do you say to a convicted felon in Providence? "Hello, Mr. Mayor."
Re: Two questions
Author: 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
Re: Two questions
Author: Dave Mason
Date: Tue, 06 Oct 1992 14:34
Date: Tue, 06 Oct 1992 14:34
38 lines
1535 bytes
1535 bytes
In article <1992Oct2.164936.20520@cs.brown.edu> sdm@cs.brown.edu (Scott Meyers) writes:
> 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.
Dijkstra's guarded command language, although the syntax is:
x,y := y,x
@book{gries:science,
title="The Science of Programming",
author="David Gries",
publisher="Springer-Verlag",
year=1981,
address=SV-addr,
isbn="0-387-90641-X",
call="QA76.6.G747"
}
SML also allows this, with syntax:
val (x,y) = (y,x)
@book{
AUTHOR={Robin Milner and Mads Tofte and Robert Harper},
TITLE={The definition of Standard ML},
address={Cambridge, Mass.},
publisher={MIT Press},
year=1990,
ISBN="0262132559"
}
../Dave
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads