Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!tektronix!tekcrl!tekgvs!toma From: toma@tekgvs.LABS.TEK.COM (Tom Almy) Newsgroups: comp.lang.forth Subject: Re: The most fantastically fun word in FORTH ever! Message-ID: <5096@tekgvs.LABS.TEK.COM> Date: 8 May 89 20:47:28 GMT References: <3219@cosmo.UUCP> <1993@umbc3.UMBC.EDU> <6716@medusa.cs.purdue.edu> Reply-To: toma@tekgvs.LABS.TEK.COM (Tom Almy) Distribution: usa Organization: Tektronix, Inc., Beaverton, OR. Lines: 41 In article <6716@medusa.cs.purdue.edu> bouma@cs.purdue.EDU (William J. Bouma) writes: >In article <1993@umbc3.UMBC.EDU> cs472226@umbc5.umbc.edu.UUCP (David Wood (CS472226)) writes: >> But I've recently rediscovered my favorite word in FORTH! >> The word is, in GS16FORTH: >> : myself LATEST PFA CFA , ; immediate >> The result: The word's CFA is compiled into the word itself. Instant >>recursion! >Nice word! >Isn't recursion in the FORTH standard yet? >Way back when I got my first first FORTH program in the form of assembly >language for a 6502 micro, it did not allow recursion. That was FIG-FORTH79 >standard. It was really stupid , since all I had to do to make recursion >work in the thing was to put the word being defined into the dictionary as >soon as it was seen, rather than after the definition was complete. The >stack in FORTH makes recursion automatic. Well, MYSELF or RECURSE or (who knows what else it might be called) is found in most implementations, and can be easily added to those Forths that don't have it. There is a good reason *not* to make a word be visible in the dictionary before it is seen -- sometimes it is nice to be able to redefine a word in terms of itself. As an example: : / DUP 0= IF ." ATTEMPT TO DIVIDE " DROP . ." BY ZERO" ABORT THEN / ; There is a nice feature in Laboratory Microsystem's Forths (and others) that allows forward referencing of colon definitions and thus mutually recursive words. It is used in this way: F: WORD-B : WORD-A ... WORD-B ... ; R: WORD-B ... WORD-A ... ; Tom Almy toma@tekgvs.labs.tek.com