Re: Java Browser for xx21
- To: cogniscu@xxxxxxx
- Subject: Re: Java Browser for xx21
- From: girling@xxxxxxxxx (Doug Girling)
- Date: Fri, 2 Feb 1996 22:47:46 -0800
- Cc: misc
- In-Reply-To: <Pine.SV4.3.91.960201094033.13302A-100000@purple> (message from Louis Frazier on Thu, 1 Feb 1996 09:53:01 -0500 (EST))
Louis,
I read your post with interest. However, while Forth & Postscript are
quite similar, there are several subtle but important differences that may
make your suggestion difficult. (I built most of a PS interpreter about 5
years ago in an attempt to develop a "data file format" for neural network
experiments. As the expession goes, it sor of got away from me...)
1. Function binding
-------------------
Consider the following:
: foo ... ;
: bar1 ... foo ... ;
: bar2 ... foo ... ;
: foo ... ; (redefine foo)
: bar3 ... foo ... ;
In Forth, bar3 will use the new foo, while bar1 and bar2 will continue to
use the old foo. In PS, all three bars will use the new foo. This is
because Forth uses static bindings, while PS uses dynamic. (LISPers will
talk about shallow and deep bindings.) Thus, one can get some really nasty
portability problems.
2. Stacks (care and feeding of)
Both Forth and PS have 2 stacks: a data stack, and a return stack. In
Forth, you can explicitly manipulate the return stack, and it is often used
as a scratchpad to hold some of the data stack while you perform some
arcane ritual on it. (We all know that Forth programmers *never* do this,
of course :-)
In PS, the return stack is implicit in that you can't access it with any
words (other than the usual call/return mechanism). PS provides a much
richer set of stack manipulation tools than Forth, which generally means
that one doesn't need to resort to fidging around with the return stack as
temporary data storage. (Note I said "generally" When you need it, its
absence is a real nuisance.)
3 Stacks (cont'd)
-----------------
If memory serves me correctly, the order of the top 2 stack elements is
swapped in PS relative to FORTH (i.e., "a b /" yields a/b on one and b/a
on the other). (It's been many years, but I think this is correct.)
4 stacks (cont'd)
-----------------
Part of Forth's beauty comes from the fact that the stack contains bunches
of 16-bit numbers (at least in Forth 78). You can push any old thing on
the stack and it doesn't care. Of course, if you want to mix data types,
you have a lot more bookkeeping to contend with...
Postscript tags all its data. Each element on the stack is a structure or
C union containing a type field and the data. This makes things really
nice for the programmer, who can push a float and an int and expect the
result to be something sensible. (It also makes the interpreter
implementer's job a little more nightmarish, or at least tedious.) Again,
portability between the 2 environments isn't quite as clean as one would
want.
-----
In many ways, Postscript is a marriage between Forth and LISP, and in many
ways, adopts the best of both features (though Chuck may not concur).
OTOH, it tends to be large and slow, and combines the clarity of FORTH with
the brevity of COBOL :-)
Just my 12.5 cent's worth,
Doug
-------------------------------v-----------------------------------------------
Doug Girling | Voice: (604)291-4428
School of Engineering Science | FAX: (604)291-4951
Simon Fraser University | email: girling@cs.sfu.ca
Burnaby, B.C. V5A 1S6 CANADA | CompuServe: 73777,50 (73777.50@compuserve.com)