Path: utzoo!attcan!uunet!snorkelwacker!tut.cis.ohio-state.edu!ucbvax!ENG.SUN.COM!wmb From: wmb@ENG.SUN.COM (Mitch Bradley) Newsgroups: comp.lang.forth Subject: Re: Why is Postscript not Forth? Message-ID: <9002121711.AA24864@jade.berkeley.edu> Date: 12 Feb 90 05:29:06 GMT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: Mitch Bradley Organization: The Internet Lines: 69 > a different language? They are fundamentally different, but first, we must look at the similarities so we can understand why they are often compared. S1) Both are mostly reverse polish (equivalently, arguments are communicated through a programmer-visible stack). S2) Both operate by looking up words in a wordlist and executing them. S3) The user can add words to the wordlist, and those words are invoked with the same syntax as pre-existing words. S4) They are both interactive; the wordlist is available at all times. Programs are developed by extending the interactive core, rather than by compiling a program then and throwing away the compiler. Forth and PostScript are compared because PostScript and Forth are the only popular reverse-polish (== stack oriented) languages . All other mainstream languages are either infix or prefix. (Note that LISP shares S1, S2, and S3). The fundamental differences: D1) PostScript is strongly typed. Forth is not typed at all. This difference is profound. It affects just about everything. D2) PostScript has one way to make a closure, i.e. { .. } . All PostScript control structures use this one basic mechanism, and are otherwise postfix. Each Forth control structure creates its own special flavor of a closure, and the syntax is not postfix. D3) This is not articulated in either language specification, but in practice, it is nearly alway true: Forth gives you pretty much direct access to machine hardware data types (addresses, integers, logical bit patterns), whereas PostScript doesn't. D4) Defining words in PostScript are postfix and can be used at any place within a definition, either while compiling the definition or while executing it. Defining words in Forth are prefix. They cannot be used while compiling a definition, and only in a restricted way while executing a definition (specifically, you cannot, for instance, easily write a Forth word which creates a word called "foo", unless you can arrange for the name "foo" to appear in the input stream at the time your word is executed). D5) PostScript defaults to run-time binding, with compile-time binding as an option; Forth uses compile-time binding, and run-time binding requires explicit coding effort to create a DEFER word or its equivalent. > Is the visible characteristic of PostScript's mixed-element stack > indicitive of an underlying and fundamental difference between Forth > and PostScript, or is it inconsequential difference? As stated above, the visibility of the stack is a similarity, and the fact that the stack elements are typed abstract objects in PostScript and untyped bit patterns in Forth is a fundamental difference. By the way, when James Gosling was first implementing the NeWS PostScript about 4 years ago, we had a long discussion about Forth implementation techniques. He thought that some of the Forth implementation techniques were clever and interesting, but we both agreed that most of those techniques are inappropriate for PostScript, because of late binding and abstract object data types. Mitch