sfk@otter.hpl.hp.com (Steve Knight) writes:
> Date: 13 Nov 92 17:32:04 GMT
> Organization: Hewlett-Packard Laboratories, Bristol, UK.
> .....
> Question: what is pop?
> ----------------------
> .....
>
> From the computer scientist's viewpoint, the most important qualities of
> Pop are :-
>
> * Garbage collection (automatic store management).
> * The language is dynamically typed (cf. Lisp).
> * Arguments and results are passed and returned via a stack which
> is open to the user to manipulate in any way.
> * Procedures are first class datatypes, can be arbitarily nested,
> and provide full-lexical scoping.
> .....
Here are a few other important features
* Incremental compilation
Pop-11 is not (usually) interpreted. Individual commands, and
procedure definitions are compiled "on the fly" to machine code and
then are immediately available for fast execution. This means you
don't have to write a file, compile it, then link in the object
code. This makes program development and testing extraordinarily
fast without the speed overhead of an interpreted system. E.g.
compiling or recompiling a hundred lines of code to extend or modify
a program that's already several megabytes in size can take a
fraction of a second on a modern machine (e.g. SPARC, 68040, MIPS),
after which executing or testing occurs immediately. (Old
versions of recompiled procedures are automatically garbage
collected. and indirect procedure calls mean that new versions
automatically replace old ones in previously compiled programs.)
Additional procedures can be compiled at any time during the running
of the program, encouraging very thorough and rapid incremental
testing and debugging. (Some AI systems extend themselves by using
the same incremental compilation mechanism at run-time as users
doing program development.)
* lightweight processes
Mechanisms are provided for creating, running, resuming "processes"
along with timed interrupt facilities so that you can build your own
scheduler inside pop. This means that a single Pop-11 process (in
Poplog) can simulate a mini-operating system. This has been used for
teaching operating system concepts to beginner computer science
students. This mechanism can be "inherited" by other Poplog
languages. E.g. it can be used to implement coroutines in Poplog
prolog. A new process can be constructed out of a procedure plus
some data to start it off, or by taking a snapshot of part of the
current control stack and saving it as a process that can be resumed
later. (Compare call/cc in Scheme)
* extendable syntax and explicit virtual machine
This is hard to summarise briefly, but the key points are as
follows:
1. Like most LISP dialects Pop-11 allows users to define
"macro" procedures that are invoked at compile time, can read in
arbitrary amounts of the current compiler text stream, rearrange
them arbitrarily (using arbitrary user-defined procedures) and then
put them back on the input stream to be read by the compiler, which,
then resumes compilation in the normal way (though more macros may
be triggered as a result). This allows special purpose sub-languages
to be defined which extend Pop-11. However, all the extensions
generated in this way must ultimately "translate" into legal Pop-11,
so it is essentially an abbreviation facility. This is true also of
Lisp macros. (#define in C provides some of this "macro expansion"
capability at compile time except that user-defined procedures are
not available at compile time.)
2. More importantly, Pop-11 also allows users to define new "syntax"
procedures. These, like macros, are activated during compilation,
and, like macros, can cause arbitrary amounts of code to be read in
and rearranged. However, instead of simply rearranging text in the
input stream, syntax words can "plant" instructions for the Poplog
Virtual Machine (PVM see below). These instructions then get
directly compiled into machine code, without first having to be
translated into legal Pop-11 as with macros. The PVM is more general
than Pop-11 itself, in the same sort of way as the "machine
language" of a modern computer is more general than the various high
level languages that are translated into it (C, Prolog, Ada, Pascal,
Lisp, etc.). This means that Pop-11 syntax words can extend the
language to produce constructs that cannot be translated into "core"
Pop-11", and to that extent they go beyond Macros (as well as
avoiding the inefficiency of rebuilding the compiler input stream).
This is how Poplog Lisp, Poplog Prolog, and Poplog ML are
implemented with their own syntax, using Poplog Pop-11; and no doubt
many other application-specific languages have been implemented the
same way by users (e.g. a commercial group working on "intelligent"
real time control for a chemical plant, found it convenient to
implement an extension to Pop-11 to encode the rules used by the
operators in taking decisions.)
3. The Poplog Virtual Machine extends the simple Forth-like
facilities of Pop-11 (push something onto the stack, pop the top of
the stack into ..., call procedure X, return from current procedure,
go to, branch if, etc. etc.) with quite a lot of sophisticated
constructs including mechanisms for handling abnormal exits,
interrogating the control chain, trapping procedure exit and entry
(and running user-specified set-up and re-set procedures), handling
both dynamic and lexical scoping, handling a stack of prolog
continuations, runtime creation of new procedures, etc. The PVM
makes it possible to implement incremental compilers for a variety
of high level languages, not all with efficiency comparable to
stand-alone implementations, but still quite tolerably fast, and
much faster than if they were interpreted. (E.g. you can build a
prolog interpreter in any Lisp system, but not an incremental prolog
compiler.) For more on the Poplog VM see
Robert Smith, Aaron Sloman, John Gibson
`POPLOG's two-level virtual machine support for interactive
languages' in
Research Directions in Cognitive Science Volume 5: Artificial
Intelligence,
eds D. Sleeman and N. Bernsen, Lawrence Earlbaum Associates, 1992
(Also Cognitive Science Research Paper 153, School of Cognitive
and computing sciences University of Sussex, Jan 1990).
The original Pop-2 virtual machine was largely invented by Robin
Popplestone in Edinburgh (now at University of Massachusetts at
Amherst, and helping to distribute Poplog in the USA and Canada).
The main designer and implementor of the current PVM is John Gibson,
at Sussex University, though various other people contributed ideas,
including Chris Mellish, who implemented the first Prolog in Poplog.
Requirements for Common Lisp and for ML caused some extensions to
the PVM which then allowed Pop-11 itself to be extended (e.g. with
lexical blocks, dynamic local expressions).
The mechanisms for adding syntactic extensions are used by Pop-11
itself, to provide useful constructs, e.g. various forms of
iteration over datastructures. Such extensions can go into the
"autoloadable" library. Later, they can be built into the main
system.
There are other relatively unusual features of Pop-11, including
properties, user-definable sub-syntax words to extend an existing
syntax form, autoloadable libraries, the treatment of arrays as
procedures (functions), the class_apply construct that allows
user-defined data-types to be treated as procedures, partial
application (analogous to but simpler and more efficient than
lexical closures), and more recently the object-oriented extensions.
Unfortunately, the only full and up to date documentation on Pop-11
consists of the online reference manual that is part of Poplog.
NOTE: the fact that users can extend the syntax of Pop-11 in all
sorts of ways can totally screw up attempts to apply formal methods
to Pop-11 programs that use these facilities. In my view the
addition of new higher level constructs making it easier to get
programs right and to extend and maintain them outweighs the
theoretically possible but not yet demonstrated benefits of formal
analysis. (Flame on formalists!)
Aaron
--
Aaron Sloman, School of Computer Science,
The University of Birmingham, B15 2TT, England
EMAIL A.Sloman@cs.bham.ac.uk OR A.Sloman@bham.ac.uk
Phone: +44-(0)21-414-3711 Fax: +44-(0)21-414-4281
|