🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.forth
Article #310

Re: Recursion forth

#310
From: Steve Schlaifer x3171 156/224
Date: Wed, 07 May 1986 04:42
38 lines
2027 bytes
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
Technical Details
Message-ID: <781@jplgodo.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!linus!philabs!cmcl2!harvard!caip!lll-crg!lll-lcc!qantel!hplabs!felix!scgvaxd!wlbr!jplgodo!steve
References: <1854@mtgzz.UUCP> <2441@yale.ARPA> <439@cit-vax.Caltech.Edu>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!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 ;