On Fri, 20 Oct 2000, Jean-Marc Lasgouttes wrote:
> The method Menu::expand in Menubackend.C has the following signature:
>
> /// Expands some special entries of the menu
> /** The entries with the following kind are exanded to a
> sequence of Command MenuItems: Lastfiles, Documents,
> ViewFormats, ExportFormats, UpdateFormats
> */
> void expand(Menu & tomenu, Buffer *) const;
>
> It would have been more reasonable to have something like
> Menu const expand(Buffer *) const;
>
> The reason I did not do it is that I was not sure what would happen:
> if you create a temporary object in a function, and return it at the
> end, is the object copied or do you return it without copy? This can
> have some importance if the object is a big vector (think 'table of
> contents').
>
> So what is the right way to return this kind of big objects?
>
> JMarc
Things are always copied on return. That's why things like reference counters
were invented; the main class holds just a pointer that points to the data
structure. Only the pointer is then copied on return.
It's an illuminating exersice to put print statements in contructors and
destructors. AMAZING how often they're called!
Angus