2 ms·
> PostScript is a lot like Lisp, where everything is an FEXPR. I view PostScript as a Forth rather than a Lisp. That may not be correct--as I'm by no means an
by bsder 5y ago
> PostScript is a lot like Lisp, where everything is an FEXPR.
I view PostScript as a Forth rather than a Lisp. That may not be correct--as I'm by no means an expert in either.
> ...because it can eval? ;)
Perty much. :)
> It had ultra-dynamic lazy scoping: It would defer evaluating the function parameters until they were actually needed by the callee (((or a function it called))), at which time it would evaluate the parameters in the CALLEE's scope.
And that hits at one of the problems that Shutt hits in his thesis, dynamic default scope (aka global variables) interacts very badly with FEXPRs (and macros and lots of other things, too).
There is a reason why everybody abandoned dynamic scoping and went to lexical scoping as soon as memory got large enough. The problem of lexical scoping is that now you have to deal with the fact that your variables need a stack. The downside of lexical scoping is the memory consumption of holding the variable bindings as recursion proceeds--that kicks up a lot of garbage to be collected and complicates your name resolution data structure. This is why Scheme was so insistent on tail calls.
Shutt deals with the scoping ambiguity by keeping the references to the environments so they can be explicitly accessed as required. Thus, your "argument evaluator" can access the required environment. Do you need the environment of the original definition? You have that as an explicit variable. Do you need the current environment? You have that as an explicit variable. Most things are "lexical scope and argument evaluation", but they don't have to be. And that's important because, as we've found out over time, if you only have one or the other, some cases don't work. (ie. short-circuit "and" likely wants the "and" from the definition environment but wants to evaluate the arguments it chooses to evaluate in the current environment)
Of course, all that costs memory and CPU (especially GC!) cycles--both of which were in short-supply in 1980 and laughably abundant in 2010 (date of Shutt's thesis).