develooper Front page | perl.perl6.language | Postings from May 2005

Binding to a sub's return value

Thread Next
Joshua Gatcomb
May 10, 2005 12:52
Binding to a sub's return value
Message ID:
I am wondering what the proper behavior of binding to a sub's return
value should be

sub some_routine {
    my $foo = 42;
    return $foo;
my $rv := some_routine();

Should $rv be bound to $foo or to a copy of $foo?  I ask because with
state() and closures, it makes a difference since the value can

sub some_rourtine {
    state $foo = 42;
    return $foo++;

My apologies if this has been previously discussed or is documented
somewhere.  I am still playing catch up.  Ok, ok - it's true - I am
looking for a little instant gratification.

Joshua Gatcomb
a.k.a. L~R

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About