Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!uxc.cso.uiuc.edu!uxc.cso.uiuc.edu!m.cs.uiuc.edu!p.cs.uiuc.edu!foote From: foote@p.cs.uiuc.edu Newsgroups: comp.lang.smalltalk Subject: Re: Tracking Interaction Histories Message-ID: <80500070@p.cs.uiuc.edu> Date: 22 Aug 89 15:00:00 GMT References: <56231@aerospace.AERO.ORG> Lines: 36 Nf-ID: #R:aerospace.AERO.ORG:56231:p.cs.uiuc.edu:80500070:000:2100 Nf-From: p.cs.uiuc.edu!foote Aug 22 10:00:00 1989 It is possible to use doesNotUnderstand: to wrap code around a given Smalltalk object, but doing this seamlessly can be tricky. Problems arise because doesNotUndertand: is not invoked until after all methods defined for a given object have been considered for execution. This means that common methods defined by Object will not be passed to a Variable object's referent, but will be executed by the Variable object itself. An insidious scheme for circumenting this problem was described by Geoffrey Pascoe in an OOPSLA '86 paper on what he called Encapsulators. He created a hierarchy of objects that do not include Object as a superclass and hence respond to a minimal number of messages. As a result, nearly all messages can be intercepted using doesNotUnderstand: and forwarded to the Encapsulator's referent. This paper also describes how Pascoe dealt with the parts of the programmer interface that break when one creates objects like this. Another potential problem with the Variable object approach is that the wrapper will in effect stick to the value rather than the object owning the variable if references to the owning object's instance variables are not carefully controlled. That is to say, the approach being discussed creates active values rather than active variables. As a result, copies of the wrapped value with the wrapper still in place can "leak" out of an object. (Of course, for some applications, this may be just what is needed.) To create active variables, one must change the way that objects reference their variables so that messages like value and value: are sent to variable objects in place of explicit loads and stores. One way to do this is to modify the compiler to generate such code when appropriate. Were Smalltalk's scheme for accessing an object's representation an explicit part of its metalevel architecture then making selective modifications to it might be easier. Since the instance access protocol has largely been subsumed into the virtual machine, this is not the case. Brian Foote Dept. of CS, U. of Illinois @ Urbana-Champaign