Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!wuarchive!udel!carroll From: carroll@udel.edu (Mark Carroll ) Newsgroups: comp.lang.forth Subject: Re: Object-oriented Forth Message-ID: <29211@nigel.ee.udel.edu> Date: 1 Sep 90 20:46:24 GMT References: <29113@nigel.ee.udel.edu> <12070@ists.ists.ca> Sender: usenet@ee.udel.edu Organization: University of Delaware Lines: 126 Nntp-Posting-Host: dewey.udel.edu In article <12070@ists.ists.ca> peterc@gkcl.UUCP (Peter Camilleri) writes: ]In article <29113@nigel.ee.udel.edu> carroll@udel.edu (Mark C. Carroll ) writes: ]] ]] ]]1> What exactly do we mean by object-orientation? ]To me, an object oriented system must exhibit the following properties: ] late binding ] polymorphism ] type checking (if any) at RUN TIME! ] the encapsulation of code and data into things called "OBJECTS" ] the hiding of private information contained within an "OBJECT" ] inheretance of object class behaviour ] We're basically saying the same thing. The only difference is that I think that it's very important to lay the "theoretical" groundwork first. Late binding, polymorphism, etc., are all actual features that together can be used to create an object-oriented system. I would prefer to decide what an object-oriented system should be, and then decide what features I need to implement it. In an object-oriented system, we want to be manipulating objects through messsages sent to the objects. This requires some sort of late binding. The use of late binding of messages to routines obviously provides polymorphism. We also want tight encapsulation of objects. Type-checking has nothing to do with OO - we can include it or not as we choose. And we also need some form of behavior inheritance. But not necessarily CLASS inheritance. ]]What form of object-orientation is most well-suited to Forth? This is ]]a much more difficult question. It helps to consider the models that ]]are available. In my opinion, there are four primary models of ]]object-orientation: [1] Loosely-typed class (Smalltalk), [2] Strongly ]]typed class (C++, Eiffel), [3] Prototyped (Self), and [4] Law Governed ]]Systems (Darwin). ]] ]]I think that we can immediately eliminate [2] (Forth has never had ]]strong declared typing, so it would be unnatural to add it for OO), ]]and [4] (Forth has always been very minimal - a Law Enforcement system ]]in the message pass mechanism would be very unforthlike). ]] ]I am familiar with [1] and [2] by direct experience. Could you elaborate ]on [3] and [4] a bit? Sure. [3] Prototyped Object Orientation: Prototyping represents a different regime of object-orientation that the traditional class based system. The idea of prototyped languages is: we want to create a system where everything is an object. Smalltalk attempted this, but came accross problems with metaclass regress, etc. Rather than deal with this, just simple say that EVERYTHING is an object, and eliminate the entire idea of classes. An object is a collection of dataslots, and methods. When you receive a message that you don't understand, instead of looking for it in your superclass, delegate it to your superobject. (In other words, rather than inheriting from an abstract entity like a class, just directly delegate messages to some other object.) In terms of modeling, this is very much like classes - there is a simple mechanical translation from classes to prototypes. It is much simpler though, because it eliminates the enigmatic class object. [4] Law Governed Systems LGS's are also basically classless object-oriented systems. They start out similar to a system of prototypes, only they don't include any method of delegation. In the initial system, any object can be passed any message. Then, by imposing laws, the programmer can restrict or alter the passing of messages by imposing laws on the system. Once laws have been imposed, every message pass is passed through a governor. The governor examines the message, its recipient, and its sender, and decides whether to pass the message, alter the message, redirect the message, or block the message. With this system, you can impose a regime of delegation, inheritance, or anything else that you can imagine. LGSs are largely experimental, but a gentlman at Rutgers has implemented a complete one with a governor written in Prolog. (And I've written a very Small LGS around a prototype package for Scheme.) They're extremely nice, but very slow... ]I would favour [1] because of its simplicity and ]effectiveness in problem solving. It woukd be a good idea to avoid the ]rabid complexity of c++ with its multiple inheritance, multi-object tree ]and trying to avoid the issue that classes themselves should be treated as ]first class objects. (I have used both Smalltalk and C++ extensively, can ]you guess which I prefer? :-) ] I've also used both, and I very greatly prefer Smalltalk. But I think that implementing a system like either Smalltalk or C++ would be a very big mistake for Forth. If we were to lean in the direction of Classes, I think that a weak class system where classes weren't objects would be best. But I still think that the best solution in Forth is prototyping. It just seems to be the most natural idea for Forth. ][discussion of syntax deleted, I tend to agree overall.] ] ]]Now, the important question is what kind of syntax to use for actual ]]object creation. This, I'm very uncertain of. I would like to see what ]]some other folks think about an appropritae syntax before I make any ]]decision of what I like best. ]] ]In the same manner as Smalltalk, I feel that classes should be objects. ]They would be responsable for creating new objects, hold class wide data, ]and performing other "objectless" processing. The classes would be ]instances of the class MetaClass, which would be pre-existing. In the ]spirit of FORTH, MetaClass could be subclassed to allow new classes to ]be created in different ways. (Not too unlike a defining defining word) ] Actually, I really like this idea. I'm not too sure of how good an idea classes as objects are, but I does seem to be terribly Forthish to allow creation of new metaclasses. If we must have classes, I really like this idea. ]Peter Camilleri peterc@stpl.UUCP -- | Mark Craig Carroll: |"We the people want it straight for a change; | CIS Graduate Student at | cos we the people are getting tired of your games; | University of Delaware | If you insult us with cheap propaganda; | carroll@udel.edu | We'll elect a precedent to a state of mind" -Fish