On Monday 19 December 2005 07:34, Sergey Plis wrote: > Hello, > > I noticed the following semantics of Module definition in bigforth: > > only forth > order FORTH ROOT ROOT > also float definitions > order FLOAT FORTH ROOT FLOAT > Module test Module; > order FORTH FORTH ROOT FORTH > > You may see that it alters dictionary stack replacing the top > dictionary with FORTH and also replacing the current dictionary. Is > there any good reason for that?
Yes. While defining the module test, you put this vocabulary on the dictionary stack, and set it to the current definition. When you end the module, the current definition is restored to the outer module, which is "FORTH", and this module is also made the top of the vocabulary stack. Modules are also vocabularies, but the semantics of module definitions is a nested structure of modules, not a stack of vocabularies. Therefore, the reason is good. IMHO. There's also a reason why FORTH is twice in the default vocabulary stack (which you get with ONLYFORTH or after start): You don't need to put an also/previous around every temporary use of other vocabularies, so you can say float 3e 5e f+ f. or assember 5 # ax add and forth sets the top of VS back. > It seems like a good idea to not > alter the dictionary stack. At least I would assume it as a default > behaviour. Would be right if the module was orthogonal to the dictionary stack and the current definition, but that's not the case. -- Bernd Paysan "If you want it done right, you have to do it yourself" http://www.jwdt.com/~paysan/
pgpmp7Opi6YiR.pgp
Description: PGP signature
