willner@cfa.UUCP (Steve Willner) (07/22/86)
> >You could also corrupt the name field (e.g. blank fill it) to make the >word lexically unrecognizable. I think the pointer-shifting scheme is better >though, as it removes the word from the search stream altogether. > > This is almost exactly what "smudge" does. The MSB of the first byte in the > name field can be used to fool ' (tick) into missing the definition, subsequent > smudges to an already existing definition toggle the bit. > Better be careful here; this technique is highly implementation dependent. The MSB is used as the precedence bit in many implementations, but the next lower bit may be available. Also, a single word will generally not toggle the bit, because the second time "smudge" is used, it will not find the word that was previously smudged. Our particular implementation of Forth (for the Data General Nova series - I guarantee that yours is different!) uses the word LOCAL to smudge a definition and GLOBAL to "unsmudge". Another use of the "smudge" technique is to hide old definitions. This is useful in our case because we use overlays, but it may also be useful if you have many source files that are mixed and matched to make long programs. For example: : TODAY original definition ; ( lots of code, several source files, overlays, branch vocabularies, etc.) : TODAY new definition, may include the existing TODAY ; LOCAL TODAY LOCAL TODAY ( smudges both versions) GLOBAL TODAY ( unsmudges only the later version) Now if I'm in the wrong vocabulary and type TODAY, I'll get an error message rather than the old version. It should be very easy to write LOCAL in Forth, e.g. : LOCAL ', 4 - DUP @ BITMASK @ OR SWAP ! ; where 4 should be replaced by the difference (in your implementation) between the address returned by ', and the word you want to smudge and BITMASK is a variable containing the smudge bit pattern. GLOBAL is much harder to write unless you have access to the more primitive words used by ' or [']. (Send e-mail if you want to know how we do it.) I hope this is helpful. -- ------------------------------------------------------------------------- Steve Willner Phone 617-495-7123 Bitnet: willner@cfa1 60 Garden St. FTS: 830-7123 UUCP: willner@cfa Cambridge, MA 02138 USA Telex: 921428 satellite cam