develooper Front page | perl.perl5.porters | Postings from June 2011

Should lvalue subs copy read-only scalars?

Thread Next
From:
Father Chrysostomos
Date:
June 5, 2011 20:23
Subject:
Should lvalue subs copy read-only scalars?
Message ID:
CF7C7B00-5E54-4A28-AEA3-CBC83D270AFB@cpan.org
Lvalue subs, as far as I can tell, have always copied read-only scalars returned in pass-by-reference context (in for(...) or a sub’s arguments). This seems odd to me. I thought the whole point of lvalue subs was to return the actual result of the last statement, and not a copy of it.

Just as

for($$) {
  $_ = 1
}

is an error, should not the same apply to this?

for(sub :lvalue { $$ }) {
  $_ = 1
}


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