Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!apple!apple.com!Piersol From: Piersol@apple.com (Kurt Piersol) Newsgroups: comp.object Subject: Re: Reentrant code Message-ID: <4513@internal.Apple.COM> Date: 2 Oct 89 19:01:39 GMT References: <11242@eerie.acsu.Buffalo.EDU> Sender: usenet@Apple.COM Organization: Apple Computer, Inc. Lines: 39 In article <11242@eerie.acsu.Buffalo.EDU> axaris@cs.buffalo.edu (Vassilios Axaris) writes: > I have recently read somewhere (most likely a magazine article) that object > oriented code must be non reentrant. Is this statement true? For some reason, > I do not believe it is, since code is shared by objects through inheritance. > But I want to be sure... On the contrary, object-oriented code is in general highly reentrant. Since the same code may be shared by many instances of an object class, each with a different state, the code must be reentrant for the whole scheme to work. However, a given object is often not reentrant. That is to say, one generally doesn't expect context-free operations of an individual instance. Since one of the purposes of an object is to store state information on which messages can operate, one must carefully write a class if instances are to be 'reentrant'. Generally, this involves some encapsulation scheme, where the outer object appears to be reentrant because all of its messages send further messages to an encapsulated object. The encapsulated object must be passed to the 'reentrant' object before any messages are sent to it. If this seems like a lot of effort just to create a 'reentrant' object, you're correct. Usually one simply avoids this sort of encapsulation, unless there is meta-state which the 'reentrant' object needs to keep. Kurt Kurt Piersol Senior Scientist Usenet: {sun,...}!apple!Piersol Internet: Piersol@apple.com AppleLink: Piersol.k Disclaimer: The opinions presented in this flame do not in any way represent the opinions of anyone, even myself whilst I was writing it.