Sujet : Re: on Perl
De : commodorejohn (at) *nospam* gmail.com (John Ames)
Groupes : comp.unix.programmer comp.lang.misc comp.unix.shellDate : 17. Apr 2024, 21:39:55
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240417133955.00004d23@gmail.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
User-Agent : Claws Mail 4.2.0 (GTK 3.24.38; x86_64-w64-mingw32)
On Wed, 17 Apr 2024 21:52:06 +0200
David Brown <
david.brown@hesbynett.no> wrote:
I think that when finding the definition of a word, Forth just
searches back through the stack of definitions until it gets a hit.
And if that word definition uses other non-primitive words, it goes
backwards from where it currently is, looking only at definitions
from before the current word was defined. Is that right? And if so,
can you do "forward declarations", and mutual recursion somehow?
That's my understanding, yes; essentially, it's a consequence of the
fact that definitions are stored as a list of pointers, and re-
definitions are simply appended to the dictionary without going back
through the rest of it to update any pointers to the prior definition.
A strange design choice, but they're consistent with it.
Forward declarations are possible using the CREATE ... DOES> construct,
which creates a definition that invokes a function pointer which can be
changed later. I dunno about mutual recursion, but it wouldn't shock me
if the same trick could be applied for that.
(And yes, if we ought to pare this back to comp.lang.misc we certainly
can.)