home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / objectiv / 690 < prev    next >
Encoding:
Text File  |  1992-12-13  |  1.8 KB  |  49 lines

  1. Newsgroups: comp.lang.objective-c
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!hpscit.sc.hp.com!hpuerca.atl.hp.com!sailer
  3. From: sailer@hpuerca.atl.hp.com (Lee Sailer)
  4. Subject: Re: Advice on accepting/returning objects vs. copies of objects
  5. Message-ID: <Bz5ws6.7sz@hpuerca.atl.hp.com>
  6. Date: Sat, 12 Dec 1992 19:57:41 GMT
  7. Distribution: usa
  8. References: <1992Dec7.212541.20646@colorado.edu>
  9. Organization: Hewlett-Packard NARC Atlanta
  10. X-Newsreader: Tin 1.1.3 PL5
  11. Lines: 36
  12.  
  13. Adam Fedor (fedor@hopper.Colorado.EDU) wrote:
  14. : I think I have an answer to this, but since I'm very new to Obj-C, I thought
  15. : I'd ask:
  16. : Say I have an instance of a class List (myList) that stores a 
  17. : bunch of objects.  If some
  18. : client asks for an object and myList returns it, instead of a copy 
  19. : of the object, this leaves open the possibility that the client may 
  20. : change and/or even free the object without myList knowing about - with
  21. : disasterous consequences.
  22.  
  23. I would distinguish two cases:
  24.  
  25. 1.  You use a List to store some objects of *yours*  that is, you create
  26. them, and you insert them in the list, and so on.  When you ask the List
  27. to return one of them to you, you just get an id, and that is OK.  If
  28. you are foolish enough to free it, and thus confuse your List object,
  29. that's your problem.  After all, its your program.
  30.  
  31. 2.  Some object that provides you services stores a bunch of object id's
  32. in a List object.  Later, according to the services offered, you retrieve
  33. an object from this List.  If you free this object, you are freeing an
  34. object that "belongs" to someone else, which feels bad to me.  Again,
  35. two cases: a)  You promise not to.  b)  You can, and the List object
  36. needs to always check to see if it has a valid object before it frees
  37. it or returns it.
  38.  
  39. onward...
  40.  
  41. BTW--what'd you do?
  42.  
  43. -- 
  44. Lee Sailer
  45.  
  46.                     - Let's leave my employer
  47.                       out of this, OK?
  48.