home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!att!allegra!alice!ark
- From: ark@alice.att.com (Andrew Koenig)
- Newsgroups: comp.lang.c++
- Subject: Re: Renew?
- Message-ID: <23316@alice.att.com>
- Date: 26 Jul 92 02:29:52 GMT
- Article-I.D.: alice.23316
- References: <1992Jul5.002414.390@frumious.uucp> <THOTH.92Jul25110048@wave.cis.ufl.edu> <23315@alice.att.com> <1992Jul25.151227.8156@hemlock.cray.com>
- Reply-To: ark@alice.UUCP ()
- Organization: AT&T Bell Laboratories, Liberty Corner NJ
- Lines: 51
-
- In article <1992Jul25.151227.8156@hemlock.cray.com> de@cray.com (Duane Eitzen) writes:
-
- > To restate the problem: if your C++ is actually just a C++ to C translator,
- > you can't use realloc() in your implementation of renew.
-
- > This is true. Two ways around this: one is to implement your own
- > memory management (difficult, as you say). The other is to take
- > advantage of the fact that renew can do the move every time and still
- > adhere to the specification (although not providing the implied
- > performance gains). With this approach, renew can be implemented with
- > only malloc().
-
- Yes indeed.
-
- > So in the worst case, renew would just be short hand for a new, a bunch
- > of copies and a delete. With a good compiler and a little luck, it
- > could provide significant performance gains. This is all that realloc()
- > claims to be now. And I like realloc.
-
- Yes again.
-
- Incidentally, I pointed out in an article a while ago that virtually the
- same effect could be obtained with an appropriate template function
- in the run-time library:
-
- template <class T> T* renew (T*, size_t);
-
- So one interesting question is whether any changes to the language are
- actually necessary at all.
-
- The main disadvantage of a library function is that I don't see how to
- duplicate the effect of placement arguments in new-expressions. That is,
- I can say
-
- new(super_duper_fast_memory()) T;
-
- where super_duper_fast_memory represents a function that might, for
- example, allocate a block of appropriate memory and return a pointer to it.
- I don't see quite how to reconcile this with a renew library function,
- and it's not clear whether this is even important.
-
- > On the topic of submitting a proposal: how does one do this? How
- > much time should one expect to spend doing it? What percentage of
- > external proposals are successful?
-
- Read the recent (a few months ago) Sigplan article about how to propose
- a language extension. If you can't get your hands on it, send me email
- and I'll make sure you get a copy.
- --
- --Andrew Koenig
- ark@europa.att.com
-