home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11556 < prev    next >
Encoding:
Internet Message Format  |  1992-07-25  |  2.5 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!att!allegra!alice!ark
  2. From: ark@alice.att.com (Andrew Koenig)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Renew?
  5. Message-ID: <23316@alice.att.com>
  6. Date: 26 Jul 92 02:29:52 GMT
  7. Article-I.D.: alice.23316
  8. References: <1992Jul5.002414.390@frumious.uucp> <THOTH.92Jul25110048@wave.cis.ufl.edu> <23315@alice.att.com> <1992Jul25.151227.8156@hemlock.cray.com>
  9. Reply-To: ark@alice.UUCP ()
  10. Organization: AT&T Bell Laboratories, Liberty Corner NJ
  11. Lines: 51
  12.  
  13. In article <1992Jul25.151227.8156@hemlock.cray.com> de@cray.com (Duane Eitzen) writes:
  14.  
  15. > To restate the problem: if your C++ is actually just a C++ to C translator,
  16. > you can't use realloc() in your implementation of renew.
  17.  
  18. > This is true. Two ways around this: one is to implement your own
  19. > memory management (difficult, as you say). The other is to take
  20. > advantage of the fact that renew can do the move every time and still
  21. > adhere to the specification (although not providing the implied
  22. > performance gains). With this approach, renew can be implemented with
  23. > only malloc().
  24.  
  25. Yes indeed.
  26.  
  27. > So in the worst case, renew would just be short hand for a new, a bunch
  28. > of copies and a delete. With a good compiler and a little luck, it
  29. > could provide significant performance gains. This is all that realloc()
  30. > claims to be now. And I like realloc.
  31.  
  32. Yes again.
  33.  
  34. Incidentally, I pointed out in an article a while ago that virtually the
  35. same effect could be obtained with an appropriate template function
  36. in the run-time library:
  37.  
  38.     template <class T> T* renew (T*, size_t);
  39.  
  40. So one interesting question is whether any changes to the language are
  41. actually necessary at all.
  42.  
  43. The main disadvantage of a library function is that I don't see how to
  44. duplicate the effect of placement arguments in new-expressions.  That is,
  45. I can say
  46.  
  47.     new(super_duper_fast_memory()) T;
  48.  
  49. where super_duper_fast_memory represents a function that might, for
  50. example, allocate a block of appropriate memory and return a pointer to it.
  51. I don't see quite how to reconcile this with a renew library function,
  52. and it's not clear whether this is even important.
  53.  
  54. > On the topic of submitting a proposal: how does one do this? How
  55. > much time should one expect to spend doing it? What percentage of
  56. > external proposals are successful?
  57.  
  58. Read the recent (a few months ago) Sigplan article about how to propose
  59. a language extension.  If you can't get your hands on it, send me email
  60. and I'll make sure you get a copy.
  61. -- 
  62.                 --Andrew Koenig
  63.                   ark@europa.att.com
  64.