Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu!pitt!willett!dwp From: dwp@willett.pgh.pa.us (Doug Philips) Newsgroups: comp.lang.forth Subject: What makes Forth Forth Message-ID: <2097.UUL1.3#5129@willett.pgh.pa.us> Date: 12 Dec 90 16:30:17 GMT Organization: String, Scotch tape, and Paperclips. (in Pgh, PA) Lines: 41 In <9012092322.AA04013@ucbvax.Berkeley.EDU>, UNBCIC@BRFAPESP.BITNET writes: > > > I *DO* see an objection -- and I > > >regard a strength of Forth as the ability to add new objects with > > >first class status. This ability comes from the fact that the Forth > > >programmer has access to the language at the level at which primary > > >objects are introduced... > > > Well, what do you say to the C++/Ada/Smalltalk people then. They can > > certainly do that too. > > VOCABULARY COMPLEX COMPLEX DEFINITIONS > : VARIABLE CREATE 2 CELLS ALLOT ; > : + [ FORTH ] ROT + ROT ROT + SWAP ; > : - [ FORTH ] ROT - ROT ROT - SWAP ; > : SWAP 2SWAP ; > : ! [ FORTH ] ROT OVER ! 2+ ! ; > : @ [ FORTH ] DUP @ SWAP 2+ @ ; > : . [ FORTH ] . ?DUP IF 0> IF ." +" THEN . ." i" THEN ; > > FORTH DEFINITIONS > > COMPLEX [examples elided... -dwp] [Donning devil's advocate hat here...] Of course, not all Forth's have vocabularies. Even those that do don't all work the same (witness the headaches this caused the X3J14 TC.) Of course you can do the same kind of thing using an OOF, but thats a horse of a different can of worms. Second, the use of vocabularies as you show here has the same kind of flaw that HEX DECIMAL and OCTAL do. It is easy to forget which vocabulary is currently active. That is one reason why some have experimented with prefix and postfix "base qualifiers" on numeric constants. I think a better case for "making first class objects" would be using defining words, but I'm not sure. -Doug --- Preferred: dwp@willett.pgh.pa.us Ok: {pitt,sei,uunet}!willett!dwp