Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!brutus.cs.uiuc.edu!apple!Apple.COM!lsr From: lsr@Apple.COM (Larry Rosenstein) Newsgroups: comp.sys.mac.programmer Subject: Re: methods or functions in oo programming Message-ID: <4627@internal.Apple.COM> Date: 10 Oct 89 18:00:37 GMT Sender: usenet@Apple.COM Organization: Objects-R-Us, Apple Computer, Inc. Lines: 29 References:<2616.252ca3bb@bmc.uu.se> <4606@internal.Apple.COM> <2621.2531be57@bmc.uu.se> In article <2621.2531be57@bmc.uu.se> Mats.Sundvall@bmc.uu.se writes: > The problem I had to understand how to implement this "method" was that > it takes two objects and you get one new object that is the sum of the > two original objects. I guess I implement it as a method and pass the > other object to the method. Then I have to dispose that object as it > will not exist anymore. Since THINK C has no garbage collection, you have to adopt some conventions for memory management. It doesn't really matter if the operation is a standard function or a method, you still need to allocate a new object and worry about the old objects being combined. The latter seems to be a higher level issue. In other words, the code that calls the LIGATE method should also worry about what to do with the input objects. The other issue is whether the method should create the new object. The problem here is that the method has to choose the class of object to create and wire it into the code. One alternative is to pass a pointer to the "destination" object and have the LIGATE method fill it in. Alternatively, you can "clone" (no pun intended) one of the input objects so the result would be of the same class. Larry Rosenstein, Apple Computer, Inc. Object Specialist Internet: lsr@Apple.com UUCP: {nsc, sun}!apple!lsr AppleLink: Rosenstein1