4 ms·
Oh wow, that's old school, and brings me back. I haven't thought of "SMUDGE" in a long time! One thing I love about FORTH is how completely off-the-wall and arb
by DonHopkins 7y ago
Oh wow, that's old school, and brings me back. I haven't thought of "SMUDGE" in a long time! One thing I love about FORTH is how completely off-the-wall and arbitrary some of the words are, even weirder than LISP's CAR and CDR. Most modern FORTH don't have SMUDGE any more, which has been replaced by HIDE and REVEAL.
Perl programmers may savor and fetishize their weird arbitrary unreadable code like letter-sparse sigil-saturated line noise, but Perl can't hold a candle to the subtle beauty and enigmatically punctuated surrealistic symmetry of FORTH code:
8 : BNF: [COMPILE] : SMUDGE COMPILE <BNF ; IMMEDIATE
9 : ;BNF COMPILE BNF> SMUDGE [COMPILE] ; ; IMMEDIATE
>b) Line 9 shows a recursive production, <S>. During the definition of a production, its name is automatically unSMUDGEd.
Of course it's still possible to write self documenting FORTH code:
: C(-; LICK SMILE NOSE WINK ;
comp.lang.forth: Why smudge?
https://groups.google.com/forum/#!topic/comp.lang.forth/olO-VHXJa1Q%5B1-25%5D https://groups.google.com/forum/#!topic/comp.lang.forth/olO-...
>Does "smudge" have any other use than to stop the current word being
found during a dictionary lookup? If not, then its only use would
seem to be to allow a word to be defined in terms of another (older)
word with the same name. Are there some useful things that can be
done with this ability that make up for the (minor) extra complication?
My other favorite (and much more useful and powerful for metaprogramming) FORTH words are <BUILDS and DOES>, but <BUILDS has been replaced by CREATE now, so they don't look as cool when used together.
http://amforth.sourceforge.net/TG/recipes/Builds.html http://amforth.sourceforge.net/TG/recipes/Builds.html
<BUILDS is the older sibling of CREATE. It has been in use in pre-ANSI Forth’s and is still around as an supplemental tool. It is a parsing word that takes the next word from the input source and creates a dictionary entry in the current word list. Unlike CREATE it does not add an execution token. Thus the word list entry created is unfinished and calling it will crash the system.
The definition of the word list entry is finished with the DOES> section, that makes the word list entry a proper callable word.
The big advantage over CREATE is that CREATE requires a rewrite of the contents of the execution token. That is on microcontrollers with the flash based dictionary only possible if a single cell can be re-programmed. The Atmegas can do that with little efforts, the MSP430 lacks essential ressources to do so.
From the programming perspective there are no differences. <BUILDS can safely replace CREATE in defining words that contain a DOES> section as well. All other occurances of CREATE should remain unchanged.
: constant create , does> @i ;
\ or
: constant <builds , does> @i ;
- dvdkhlng 7y ago> Most modern FORTH don't have SMUDGE any more, which has been replaced by HIDE and REVEAL. I think, the modern Forths (i.e. since 1994 ANS Forth standard) need neither HIDE nor REVEAL as these are made superflous by RECURSE. Other edge cases could be handled using a mechanism like DEFER [1] (which can be implemented in terms of ANS Standard words). Just looking through the manual, even the modern Gforth has something like RECURSIVE [2] which is just a differently named implementation of REVEAL. [1] http://www.complang.tuwien.ac.at/forth/gforth/Docs-html/Deferred-Words.html http://www.complang.tuwien.ac.at/forth/gforth/Docs-html/Defe... https://forth-standard.org/standard/core/RECURSE https://forth-standard.org/standard/core/RECURSE [2] http://www.complang.tuwien.ac.at/forth/gforth/Docs-html/Calls-and-returns.html#Calls-and-returns http://www.complang.tuwien.ac.at/forth/gforth/Docs-html/Call...
- DonHopkins 7y agoOne thing I love about SMUDGE is that SMUDGING again undoes the effect. If only that worked for my glasses. DEFER is great! But the word that resolves it should have been named REFED.