Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!pt.cs.cmu.edu!dsl.pitt.edu!pitt!willett!dwp From: dwp@willett.pgh.pa.us (Doug Philips) Newsgroups: comp.lang.forth Subject: Re: ... and zen there were objects. Message-ID: <1531.UUL1.3#5129@willett.pgh.pa.us> Date: 16 Aug 90 04:52:31 GMT References: <1990Aug15.071510.3363@tukki.jyu.fi> Organization: String, Scotch tape, and Paperclips. (in Pgh, PA) Lines: 41 In <1990Aug15.071510.3363@tukki.jyu.fi>, tsaari@tukki.jyu.fi (Antero Taivalsaari) writes: > However, his [Pountain's] 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 > > 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). Agreed. I think that is better than what he had in the book. I still don't like the prefix nature of '\ message' though. > 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. Yes, the issue of method lookup is an efficiency stickler. Given the SEND form above it would be easy to add all kinds of tricks to speed up method lookup and still preserve the correct semantics. (dictionaries, method caches, hashed method structures, hybrids, etc.) -Doug --- Preferred: ( dwp@willett.pgh.pa.us OR ...!{sei,pitt}!willett!dwp ) Daily: ...!{uunet,nfsun}!willett!dwp [last resort: dwp@vega.fac.cs.cmu.edu]