Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!sdd.hp.com!decwrl!apple!snorkelwacker!bloom-beacon!eru!luth!sunic!tut!tukki.jyu.fi!tsaari From: tsaari@tukki.jyu.fi (Antero Taivalsaari) Newsgroups: comp.lang.forth Subject: Re: ... and zen there were objects. Message-ID: <1990Aug15.071510.3363@tukki.jyu.fi> Date: 15 Aug 90 07:15:10 GMT References: <1990Aug7.081509.2315@idacom.uucp> <1498.UUL1.3#5129@willett.pgh.pa.us> Sender: tsaari@jyu.fi Organization: University of Jyvaskyla, Finland Lines: 50 In message <1498.UUL1.3#5129@willett.pgh.pa.us> (Doug Philips) writes: >What I think is wrong with Object Oriented Extensions to Forth: > >All the OOEF's I have seen so far involve active objects or messages >or both. By active I mean that the words are IMMEDIATE words. > >Take for example Pountain's system as described in his book. ... My personal opinion is that Pountain's book - although it is rather well written - is not that good in the object-oriented sense. However, his earlier paper in JFAR (vol 3, nr 3, 1986, p.51-73) introduces much more elegant object-oriented extensions to Forth. In these extensions, the syntax for message sending is: PushArg PushArg Object \ message The word '\' is a special message operator that simply takes an address from the top of stack and considers it as the receiver of the message. By using this solution, the receiver object and the message need not have any syntactic relationship to each other. It is very easy to pass objects around in the system, since they can be referred to by simple addresses. By using this kind of solution, you can easily have anonymous objects; also, you can easily write words that return objects on the top of the stack (both of these are, indeed, VERY fundamental operations in object-oriented programming). I have been programming with these kind of OOP extensions to Forth about three years now, heavily extending and modifying Pountain's original code and I am quite convinced that this is the right way to do message passing in Forth. However, if a more postfix solution is desired, an alternative syntax could also be (as you suggest): PushArg PushArg " message" Object SEND Again, 'SEND' is a special word that simply takes an address from the top of stack and considers it as the receiver of the message. 'Message' is a string whose address will also be passed to the message operator 'SEND'. In Pountain's JFAR code, this kind of solution is used internally by the system; however, in his code message strings are first hashed to integers to improve the efficiency of late binding. Regards, Antero Taivalsaari University of Jyvaskyla, Finland tsaari@jyu.fi