Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!harvard!caip!lll-crg!lll-lcc!qantel!hplabs!felix!scgvaxd!wlbr!jplgodo!steve From: steve@jplgodo.UUCP (Steve Schlaifer x3171 156/224) Newsgroups: net.lang.forth Subject: Re: Recursion forth Message-ID: <781@jplgodo.UUCP> Date: Wed, 7-May-86 00:42:35 EDT Article-I.D.: jplgodo.781 Posted: Wed May 7 00:42:35 1986 Date-Received: Sat, 10-May-86 14:18:22 EDT References: <1854@mtgzz.UUCP> <2441@yale.ARPA> <439@cit-vax.Caltech.Edu> Organization: Jet Propulsion Labs, Pasadena, CA Lines: 38 Summary: don't forget to smudge before ; In article <439@cit-vax.Caltech.Edu>, alfke@cit-vax.Caltech.Edu (J. Peter Alfke) writes: > In FIG-influenced versions of FORTH, each word has a 'smudge' bit in its > header. This bit is normally off, but is set while the word is in the > process of being defined. The smudge bit inhibits recognition of the word > in a dictionary search. > > The purpose of this is to let you redefine a word and have references to > the word call the old version, i.e. > > : cr crcount @ 1+ crcount ! cr ; ( keep track of cr's) > > To defeat this in special cases (recursion), there's a word called > 'smudge' which toggles this bit in the most-recently-defined word. > So: > > : fact smudge > ...blah blah blah, including calls to fact which are > real recursive calls... > ; > This is more or less correct. However, SMUDGE is not usually IMMEDIATE so you need to do a : FACT [ SMUDGE ] ...blah blah blah and when ; executes it will do a SMUDGE which toggles the bit so you need : FACT [ SMUDGE ] ...blah blah blah [ SMUDGE ] ; Personally, I find the use of MYSELF clearer and less prone to errors like forgetting the [ ] stuff needed above. -- ...smeagol\ Steve Schlaifer ......wlbr->!jplgodo!steve Advance Projects Group, Jet Propulsion Labs ....group3/ 4800 Oak Grove Drive, M/S 156/204 Pasadena, California, 91109 +1 818 354 3171