Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!purdue!bouma From: bouma@cs.purdue.EDU (William J. Bouma) Newsgroups: comp.lang.forth Subject: Re: The most fantastically fun word in FORTH ever! Summary: recursion in FORTH Message-ID: <6716@medusa.cs.purdue.edu> Date: 5 May 89 20:54:54 GMT References: <3219@cosmo.UUCP> <1993@umbc3.UMBC.EDU> Distribution: usa Organization: Department of Computer Science, Purdue University Lines: 32 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! Sure, you >could talk about WISC hardware and the latest version of FORTH for x >system, but how often can one word provoke such enthusiasm? > The word is, in GS16FORTH: > : myself LATEST PFA CFA , ; immediate > The result: The word's CFA is compiled into the word itself. Instant >recursion! The word now calls itself! Used indiscriminately, it will do >such nasty things as infinite loops, blown stacks, and other >heinousness. > -David Wood >************************************************************************ 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. Could someone send|tell me how to get a description of the current FORTH standard? : unlink [compile] ' dup lfa @ swap nfa context @ @ dup >r begin r> drop pfa lfa dup >r @ 2dup = until 2drop r> ! ; -- Bill || ...!purdue!bouma