I gather this discussion started on comp.lang.misc and then was
cross-posted to comp.lang.pop. Readers of comp.lang.misc may be
interested to know that Poplog, including Pop-11 is now available
free of charge, including sources. See
ftp://ftp.cs.bham.ac.uk/pub/dist/poplog/freepoplog.html
richard@starburst.demon.co.uk (Richard Wendland) wrote:
> Date: Sun, 15 Aug 1999 00:13:39 +0000
>
> "Andy Glew" <glew@cs.wisc.edu> writes:
>
> >a :=: b is cool,
> >but I think that a,b := b,a
> >or a := b, b := a
> > (where , is the "parallel" separator for unordered code)
> >is more general, and extends to arbitrary permutations:
>
> POP-2 had this in 1968. Was this the first language with this feature?
Not if forth came first?
> The syntax was different, with the rvalue on the RHS:
>
> a, b -> a -> b;
>
> POP-2 had an explicit evaluation stack, but rvalues weren't stacked as
> I recall - perhaps the reason for the assignment operator for each rvalue.
I don't know what you mean by stacking rvalues. See the comment on
multiple assignment below.
>
> You could have fun with the explicit stack:
>
> a,b; add(); # same as add(a,b)
> ->x ->y; x,y; # swap top 2 stack items
>
> POP-2 also had a neat form of closures, called partial application, where
> you could freeze in some function parameters into a new function.
>
> mult(% 2 %) -> mult2;
> mult2(3) -> six;
>
> I've always been glad POP-2 was my first programming language.
> --
> Richard Wendland richard@starburst.demon.co.uk
Pop-11 which is the latest version of the Pop family of languages
(i.e. derived from Pop2 and its precursors) still has these
features, along with a new multiple assignment.
The integer division operator "//" returns two results, the
remainder and the quotient. So you could always write
num1 // num2 -> quotient -> remainder;
You can now also express this as
num1 // num2 ->(remainder, quotient)
Thus swapping values of two variables, becomes
x, y -> (y, x)
which compiles to the same code as
x, y -> x-> y;
Using the new syntax makes it much easier to write what you intend
the first time instead of waiting for bugs to show up.
The new syntax is also extended to the format for defining a
procedure which returns multiple results. E.g. the following
procedure, which uses the built in function "hd" for the first
element of a list, and the library function "last", is given a list
a returns its first and last element, or false and false, if the
list is empty:
define first_and_final(list) -> (first, final);
if null(list) then
false, false -> (first, list)
else
hd(list), last(list) ->(first, final)
endif
enddefine;
first_and_final([a b c d]) =>
** a d
In Pop-11 you can also "assign to" a field of a data-structure,
using the fact that field accessor functions are usually "doublets",
i.e. they have an associated updater function, which is accessed
automatically when the function is run in "update mode". E.g. To
change the first element of a list
x -> hd(list);
So if you wanted to swap the first and last elements of a list you
could do:
hd(list), last(list) -> (last(list), hd(list));
Update mode can be inherited inside a conditional expression. eg.
x -> if x > 10 then last(list) else hd(list) endif;
will put x at the end or the front of the list depending whether x
is > 10.
Another change in Pop-11 is that when variables are declared it is
now possible to initialise them, using "=".
vars x = 99;
is equivalent to
vars x;
99 -> x;
But you can also do multiple initialisations:
vars (remainder, quotient) = (x // y);
(and similarly with "lvars" used for lexically scoped identifiers).
There is more information in the online (slightly out of date)
Pop11 primer
ftp://ftp.cs.bham.ac.uk/pub/dist/poplog/primer/START.html
And for a comprehensive and fairly technical overview of the Poplog
virtual machine, which is at the core of Pop-11, see:
ftp://ftp.cs.bham.ac.uk/pub/dist/poplog/doc/popref/vmcode
Aaron
==
--
Aaron Sloman, ( http://www.cs.bham.ac.uk/~axs/ )
School of Computer Science, The University of Birmingham, B15 2TT, UK
EMAIL A.Sloman AT cs.bham.ac.uk (NB: Anti Spam address)
PAPERS: ftp://ftp.cs.bham.ac.uk/pub/groups/cog_affect/0-INDEX.html
|