marmar@mtk.UUCP (Mark Martino) (11/28/89)
When I first looked at PostScript, I viewed it as Forth with some elaborate graphic words. I still believe one could do the same things PostScript does by using Forth with graphic words, but I've discovered quite a few differences between Forth and PostScript. 1) In PostScript, all operands on the operand stack are eight bytes long. Some of them include a pointer to other data. 2) There are sixteen data types in PostScript. 3) Although I haven't made much use of this feature, it is true that in PostScript one can use any of the sixteen data types as a key to find anything else in a dictionary. I don't think you can do this in Forth, but like I said, I'm not sure how handy this is anyway. 4) PostScript tags everything you create with a save level number. It uses this number as a mechanism for memory allocation via the operators "save" and "restore". The tag is part of the eight bytes in an operand. 5) This next one may be implementation dependent, but the two interpreters I've looked at allow, even require, that you be able to call the interpreter recursively. 6) A PostScript interpreter takes over 300 Kbytes of compiled code. And I have to differ with conventional wisdom here. The amount of code is NOT just because of "a rich set of graphic operators". Forth could draw the same lines and paint the same pictures for a lot less code. What takes up the space in PostScript is the data structures it uses and the operators dedicated to handling these structures. Also, except for one implemenation in Forth, PostScript is written in C and a little assembly language. 7) A large part of PostScript is aimed at creating lovely fonts and it does this very well. One other thing, PostScript was intended to generate images in a way that would reduce the amount of transmitted data. Although Forth started out controlling telescopes, it has a more general purpose than PostScript. general charter than that
A-PIRARD@BLIULG11.BITNET (Andr'e PIRARD) (11/30/89)
>quite a few differences between Forth and PostScript. > >5) This next one may be implementation dependent, but the two > interpreters I've looked at allow, even require, that you be able to > call the interpreter recursively. If Forth can be said to *implement* a nonrecursive text interpreter, it's just because one didn't care to. Interpreter recursivity is a simple matter of pushing aside some user variables, but also, worst hitch, that it operates on a dedicated location for input stream text, viz. TIB or BLOCK. Pushing text is not easy, but having the TIB relocatable and pushing it's pointer is not difficult in most systems. But doesn't all this feel the other way round? Shouldn't the basic primitive for interpretation be something called like EVALUATE that would take any string anywhere and interpret it after saving the previous context? Then INTERPRET could be built to invoke EVALUATE with specific input. But, after all, the TIB itself is a shabby concept: would one dare using QUERY in an application and overlay the main input stream? No, QUIT itself should be recursive (and I'd call it something like INTERACT then) and the TIB would be just a local data area made known externally for the purpose of using WORD. This is useful, for example, when a debugger gets to prompt the user for commands. The main disease is that Forth does not envision storage allocation elsewhere than in the dictionary. But if allocation is meant towards recursivity, a heap is not needed, a stack suffices and, again, this is a trivial matter. All in all, plus error recovery, operating system interface and other goodies, this raises Forth towards the rank of usability of other languages in the field of operating systems applications. This was my goal when I wrote Comforth, but I have been hindered by having to comply with standards. Going further would have had me to call it Froth. I wish I had more time and less distance to try convince the ANSI committee about this. Andr'e PIRARD SEGI Univ. de Li`ege B26 - Sart Tilman B-4000 Li`ege 1 (Belgium) A-PIRARD@BLIULG11 on EARN alias BITNET "GOTO hell" he commanded nervously. "Stack full" it refused ironically. But only he smiled.