The shift to lexical arguments by default is long overdue. Personally, I
see dynamic locals as a fudge which was forced on us by the limited
architecture of the Elliot 4130, certain misplaced ideas about usefulness
in debugging and a lack of adequate commitment to the functional
paradigm. My own style of programming has become to bundle things which
would be put in dlocal variables in an "environment" parameter to
porcedures.
The primary problem with -most- pattern-matching is that it militates
against abstraction. This screws up its usefulness in Prolog and ML, making
them worse languages than they need be. POP-11 patterns also suffer from
this problem.
The syntax introduced into POP-11 to allow -lvars- binding off the stack
e.g. goes some way towards abstract matching, but of course it does not
allow you to reject non-matching cases.
lvars (x,y) = dest_point(P);
Incidentally, I make a lot of use of a -let- macro I wrote. This gives a
much more modern appearance to POP-11 (the funny declarations ARE
offputting in first-time encounters.)
For example, having unprotected various operators one can write:
define English(LanguageCapability);
let ;;; (1)
7 ---> = LanguageBuild(LanguageCapability),
4 * = LanguageProduct(LanguageCapability),
3 + = LanguageUnion(LanguageCapability),
2 ** = LanguageKleeneStar(LanguageCapability),
OneOf = LanguageSingleton(LanguageCapability)
in
let Det = OneOf([the a]), ;;; (2)
N = OneOf([dog cat elephant cake]),
V = OneOf([eat kissed]),
A = OneOf([greedy big bad]) **,
NP = Det * A * N ---> "NP",
VP = V * NP ---> "VP",
S = NP * VP ---> "S"
in
S ;;; (3)
endlet
endlet
enddefine;
This is a nice illustration of the higher-order properties of POP - it
can create a parser if the LanguageCapability contains parser-making
functions, or a generator if it contains generator-making functions. We get
Prolog's claimed invertibility in a really scalable form.
[Beginning with (1) we unpack the LanguageCapability, binding local
variables to the functions of the capability. We then construct the English
subset using these higher-order functions. The final result (3) is a
function providing a capability for manipulating the language, e.g. a
parser.]
Robin
|