This article includes a list ofgeneral references, butit lacks sufficient correspondinginline citations. Please help toimprove this article byintroducing more precise citations.(April 2010) (Learn how and when to remove this message) |
| POP-2 | |
|---|---|
| Paradigm | Multi-paradigm:structured,reflective,procedural |
| Family | Lisp: POP |
| Designed by | Robin Popplestone;Rod Burstall, Steve Hardy; Robert Rae, Allan Ramsay |
| Developers | University of Edinburgh University of Sussex |
| First appeared | 1970; 56 years ago (1970) |
| Stable release | 1975 / 1975; 51 years ago (1975) |
| Typing discipline | dynamic |
| Implementation language | assembly |
| Platform | Elliott 4130,ICT 1909,BESM-6,PDP-10,PDP-11 |
| OS | George,TOPS-10,Unix |
| License | Proprietary |
| Majorimplementations | |
| WPOP | |
| Dialects | |
| POP-10 | |
| Influenced by | |
| Lisp,ALGOL 60,COWSEL (renamed POP-1) | |
| Influenced | |
| POP-11 | |
POP-2 (also calledPOP2) is aprogramming language developed around 1970 from the earlier language POP-1 (developed by Robin Popplestone in 1968, originally namedCOWSEL) byRobin Popplestone andRod Burstall at theUniversity of Edinburgh. It drew roots from many sources: the languagesLisp andALGOL 60, and theoretical ideas fromPeter J. Landin. It used anincremental compiler, which gave it some of the flexibility of aninterpreted language, including allowing new function definitions at run time and modification of function definitions while a program runs (both of which are features ofdynamic compilation), without the overhead of an interpreted language.[1]
POP-2'ssyntax isALGOL-like, except thatassignments are in reverse order: instead of writing
a := 3;
one writes
3 -> a;
The reason for this is that the language has explicit notion of anoperand stack. Thus, the prior assignment can be written as two separatestatements:
3;
which evaluates the value 3 and leaves it on the stack, and
-> a;
which pops the top value off the stack and assigns it to thevariable 'a'. Similarly, the function call
f(x, y, z);
can be written as
x, y, z; f();
(commas and semicolons being largely interchangeable) or even
x, y, z.f;
or
(x, y, z).f;
Because of thestack-based paradigm, there is no need to distinguish betweenstatements andexpressions; thus, the two constructs
if a > b then c -> e else d -> e close;
and
if a > b then c else d close -> e;
are equivalent (use ofclose, asendif hadn't become a commonend-of-if-clause notation yet).
There are no special language constructs to create arrays or record structures as they are commonly understood: instead, these are created with the aid of special builtin functions, e.g.,newarray[2] (for arrays that can contain any type of item) andnewanyarray[3] to create restricted types of items.
Thus, array element and record field accessors are simply special cases of adoublet function: this is a function that had another function attached as itsupdater,[4] which is called on the receiving side of an assignment. Thus, if the variablea contains an array, then
3 -> a(4);
is equivalent to
updater(a)(3, 4);
the builtin functionupdater returning the updater of the doublet. Of course,updater is a doublet and can be used to change the updater component of a doublet.
Variables can hold values of any type, including functions, which are first-class objects. Thus, the following constructs
function max x y; if x > y then x else y close end;
and
vars max; lambda x y; if x > y then x else y close end -> max;
are equivalent.
An interesting operation on functions ispartial application, (sometimes termedcurrying). In partial application, some number of the rightmost arguments of the function (which are the last ones placed on the stack before the function is involved) arefrozen to given values, to produce a new function of fewer arguments, which is aclosure of the original function. For instance, consider a function for computing general second-degree polynomials:
function poly2 x a b c; a * x * x + b * x + c end;
This can be bound, for instance as
vars less1squared; poly2(% 1, -2, 1%) -> less1squared;
such that the expression
less1squared(3)
applies the closure of poly2 with three arguments frozen, to the argument 3, returning the square of (3 - 1), which is 4. The application of the partially applied function causes the frozen values (in this case 1, -2, 1) to be added to whatever is already on the stack (in this case 3), after which the original function poly2 is invoked. It then uses the top four items on the stack, producing the same result as
poly2(3, 1, -2, 1)
i.e.
1*3*3 + (-2)*3 + 1
In POP-2, it was possible to define new operations (operators in modern terms).[5]
vars operation 3 +*; lambda x y; x * x + y * y end -> nonop +*
The first line declares a new operation +* with precedence (priority) 3. The second line creates a function f(x,y)=x*x+y*y, and assigns it to the newly declared operation +*.
The original version of POP-2 was implemented on anElliott 4130 computer in the University of Edinburgh (with only 64 KB RAM, doubled to 128 KB in 1972).[6]
POP-2 was ported to theICT 1900 series on a 1909 at Lancaster University by John Scott in 1968.
In the mid-1970s, POP-2 was ported toBESM-6 (POPLAN System).
In 1978 Hamish Dewar implemented a version of POP-2 specifically for use by Edinburgh University undergraduates in the AI2 (Artificial Intelligence, 2nd year level) class using theEMAS operating system. This implementation was written from scratch in the Edinburgh programming language,IMP.[7]
Later versions were implemented forComputer Technology Limited (CTL) Modular One,PDP-10,ICL 1900 series (running the operating systemGeorge). Julian Davies, in Edinburgh, implemented an extended version of POP-2, which he namedPOP-10 on the PDP-10 computer runningTOPS-10. This was the first dialect of POP-2 that treated case as significant in identifier names, used lower case for most system identifiers, and supported long identifiers with more than 8 characters.
Shortly after that, a new implementation known asWPOP (for WonderPop) was implemented by Robert Rae and Allan Ramsay in Edinburgh, on a research-council funded project. That version introduced caged address spaces, some compile-time syntactic typing (e.g., for integers and reals), and some pattern matching constructs for use with a variety ofdata structures.
In parallel with that, Steve Hardy atUniversity of Sussex implemented a subset of POP-2, which he namedPOP-11 which ran on aDigital Equipment Corporation (DEC) PDP-11/40 computer. It was originally designed to run on the DEC operating system RSX-11D, in time-shared mode for teaching, but that caused so many problems that an early version ofUnix was installed and used instead. That version of Pop-11 was written in Unixassembly language, and code was incrementally compiled to an intermediatebytecode which was interpreted. That port was completed around 1976, and as a result, Pop-11 was used in several places for teaching. To support its teaching function, many of the syntactic features of POP-2 were modified, e.g., replacingfunction ... end withdefine ... enddefine and adding a wider variety of looping constructs with closing brackets to match their opening brackets instead of the use ofclose for all loops in POP-2. Pop-11 also introduced apattern matcher for list structures, making it far easier to teachartificial intelligence (AI) programming.
Around 1980, Pop-11 was ported to aVAX-11/780 computer by Steve Hardy and John Gibson, and soon after that it was replaced by a full incremental compiler (producing machine-code instead of an interpreted intermediate code). The existence of the compiler and all its subroutines at run time made it possible to support far richer language extensions than are possible with Macros, and as a result Pop-11 was used (by Steve Hardy, Chris Mellish and John Gibson) to produce an implementation ofProlog, using the standard syntax of Prolog, and the combined system became known asPoplog, to whichCommon Lisp andStandard ML were added later. This version was later ported to a variety of machines and operating systems and as a result Pop-11 became the dominant dialect of POP-2, still available in the Poplog system.
Around 1986, a new AI company Cognitive Applications Ltd., collaborated with members of Sussex university to produce a variant of Pop-11 namedAlphaPop running on AppleMac computers, with integrated graphics. This was used for many commercial projects, and to teach AI programming in several universities. That it was implemented in an early dialect of C, using an idiosyncratic compiler made it very hard to maintain and upgrade to new versions of the Mac operating system. Also, AlphaPop was not "32-bit clean" due to the use of high address bits astag bits to signify the type of objects, which was incompatible with the use of memory above 8 Mb on later Macintoshes.