Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!BLIULG11.BITNET!A-PIRARD From: A-PIRARD@BLIULG11.BITNET (Andr'e PIRARD) Newsgroups: comp.lang.forth Subject: Re: The most fantastically fun word in FORTH ever! Message-ID: <8905081453.AA11009@jade.berkeley.edu> Date: 8 May 89 07:15:54 GMT References: Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: Forth Interest Group International List Organization: The Internet Lines: 40 David, Look at this one, not bad either. : MACRO \ create a word interpreting the rest of the line CREATE IMMEDIATE \ an immediate word 0 WORD C@ 1+ ALLOT \ with end-of-line in pfa DOES> COUNT EVALUATE ; \ and interpreting its text It's used as: MACRO FOR-SHORT any interpretable text Of course, you must have EVALUATE \ addr count -- That saves the current input stream environment, sets it to the input one and finally restores the original input stream where it was left. EVALUATE is most useful in many situations. It's standard in Comforth but shouldn't be too hard to implement in any other Forth system. Another one: : TRANSIENT \ define overlay loader CREATE \ fna fnl -- HERE C! HERE COUNT DUP 1+ ALLOT CMOVE \ store filename DOES> \ load overlay and execute synonym L>IN @ >IN ! \ regress input stream COUNT ." Loading " 2DUP TYPE SPACE OVREAD ; " filename" TRANSIENT EDIT will define a word EDIT used to load the overlay file , then execute the synonym word EDIT from that file. The trick here is that the input stream is backed to re-execute the very same word again, once the overlay is loaded. This is possible only if L>IN gives you the offset in TIB of the last word interpreted, just another one of Comforth. Forth is the kind of language to suggest wit instead of brute force. These examples are much in line with the beauty of the language itself. Any other? Andr .