Bart Lateur writes:
: On Thu, 24 Aug 2000 09:38:28 +0100, Hildo Biersma wrote:
: 
: >> I expect that we'll get more compile-time benefit from
: >> 
: >>     my HASH sub foo {
: >>         ...
: >>     }
: >> 
: >>     %bar = foo();
: >
: >Ah, the Return Value Optimization so loved in C++...
: >
: >For those who haven't seen it before, you can optimize this by passing
: >in a reference to %bar to foo() and then use that in the function.
: 
: Just a remark: this is only safe if all other references to the hash
: returned are abandoned. Otherwise you'd have an alias where you should
: have gotten a copy.

I wasn't actually considering the RVO optimization--I was only thinking
about the fact that you can do more type inferencing at compile time
from the function's signature.

However, you couldn't actually do the aliased return right now if you
wanted to--at least, not without chicanery.  Just as with the list
assignment, it might be nice to have some way to request an object
pointer assignment rather than a hash copy:

    \%bar = foo();

or some such.

Larry

Reply via email to