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

Binding to a sub's return value

Thread Next
From:
Joshua Gatcomb
Date:
May 10, 2005 12:52
Subject:
Binding to a sub's return value
Message ID:
941eab8405051012526404956f@mail.gmail.com
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
change.

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.

Cheers,
Joshua Gatcomb
a.k.a. L~R

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About