Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!haven!umbc3!umbc5.umbc.edu!cs472226 From: cs472226@umbc5.umbc.edu (David Wood (CS472226)) Newsgroups: comp.lang.forth Subject: The most fantastically fun word in FORTH ever! Message-ID: <1993@umbc3.UMBC.EDU> Date: 5 May 89 13:27:30 GMT References: <3219@cosmo.UUCP> Sender: newspost@umbc3.UMBC.EDU Reply-To: cs472226@umbc5.umbc.edu.UUCP (David Wood (CS472226)) Distribution: usa Organization: University of Maryland Baltimore Co. Lines: 31 Keywords: Okay, maybe I heaped on the adverbs a little too thick. 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 What this does is during compilation of a word, it takes the Name Field Address of the most recently entered word (which would be the one you're compiling when this appears [LATEST]), gets its Parameter Field Address [PFA], gets its Code Field Address from that [CFA], then compiles it into the dictionary [,]. The [immediate] after it means the word is executed rather than compiled during the compilation phase. 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. Error handling in the form of compilation-only protection is forthcoming (no pun intended), but if you're just a little careful, I'm sure there are people here who can find all sorts of wonderful ways to abuse it, and I want to hear about every one! -David Wood ************************************************************************ * A Mind is a Terrible Thing *** Sometime in June, this account * * to have Oozing out *** turn into a pumpkin. Help this poor * * your ears... *** system addict stay in touch with * * -- The League of *** his contacts on UseNET and/or * * Sadistic *** BitNET. All contributions will be * * Telepaths *** generously accepted through E-MAIL. * ************************************************************************