Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!cs.utexas.edu!uunet!mcvax!kth!sunic!liuida!mikpa From: mikpa@massormetrix.ida.liu.se (Mikael Patel) Newsgroups: comp.lang.forth Subject: Incapsulation and visibility in Forth Message-ID: <1@massormetrix.ida.liu.se> Date: 2 Aug 89 14:05:48 GMT Organization: Dept of Comp. and Info. Science, Univ. of Linkoping, Sweden Lines: 50 Hi, Forth-world, I am doing some work on comparing Forth with other programming languages with regard to incapsulation and visibility of symbols (Forth: words). Basically Forth seems to have only have these methods: 1) The "compilation" and "interpretation" mode mark as for words such as "if" which is marked as only usable during compilation and then always executed. 2) The use of vocabularies. This does not generally solve the problem of visibility of words as all words defined in a vocabulary are visible by a "user". 3) Don't care about internal words as these are allowed to be redefined. The problem of incapsulation and visibility has come some what of the main attributes of a programming language because of all the "noise" around object-orientation. What I would like to propose is the following three words, similar to "immediate", as mode markers to give Forth a more well defined notion of incapsulation and visibility. private ( -- ) Marks the most recently created dictionary entry as a word which is only available in the dictionary it is created in. The word is not available when the dictionary is not current. execution ( -- ) Marks the most recently created dictionary entry as a word which is only available in execution mode. compilation ( -- ) Marks the most recently created dictionary entry as a word which is only available in compilation mode. So compilation words like "if" become: : if ( flag -- ) .... ; compilation immediate So what do you say Forthians? Seen something like this or maybe an other approach! Tell us about it! Mikael Patel 'Just the place for a Snark! I have said it thrice: What I tell you three times is true.' - Lewis Carrol -