Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!nbires!hao!hplabs!tektronix!uw-beaver!cornell!rochester!ritcv!cci632!rb From: rb@cci632.UUCP (Rex Ballard) Newsgroups: net.lang.forth Subject: Re: Information Hiding in FORTH Message-ID: <240@cci632.UUCP> Date: Mon, 21-Jul-86 00:08:34 EDT Article-I.D.: cci632.240 Posted: Mon Jul 21 00:08:34 1986 Date-Received: Tue, 22-Jul-86 00:54:35 EDT References: <12110@amdcad.UUCP> <622@uvacs.UUCP> Reply-To: rb@ccird1.UUCP (Rex Ballard) Organization: CCI, Rochester Development, Rochester, NY Lines: 47 Summary: Use smudge. In article <622@uvacs.UUCP> pmy@uvacs.UUCP writes: >> I have been recently thinking of a way to implement something like the >> 'C' static scoping type in forth. This would allow a word or group of >> words to use a VARIABLE without letting the VARIABLE be visible outside >> the group; something like: >> >> HIDE randval >> >> HIDE is a word which, like tic ('), searches the dictionary for the >> target word. HIDE also keeps a trailing pointer to the previous >> word in the dictionary. There are actually two different techniques that can be used. >> a) Is this a useful construct, or is it the attempt of an >> admittedly neophyte forth programmer (me) to force >> other language ideas onto forth? >Yes, i think this is a useful construct. So useful in fact, that it has already been done as a part of the language. >> b) Can HIDE be written in forth, or must it be written in >> assembly language? >I haven't played with FORTH in a long time, but i'm fairly certain that >it could be used to implement HIDE. As I said, there are two ways to do this. The easiest is to use "Smudge". >> c) Is there another (easier) way to do this that I am not >> aware of? > >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. An extension of the "smudge" is the "vocabulary" or "context" word. In these cases, the NFA can be use to remove/enable an entire group of words from the the vocabulary. For example, when you use the "editor" word, the editor vocabulary "overrides" the forth definitions of the same name. If you want the original forth definitions, just type "forth", and you are back to the basic vocabulary. Your forth documentation should give more explanation of VOCABULARY, CONTEXT, CURRENT, and DEFINITIONS.