Make sub(){42} return a mutable value
authorFather Chrysostomos <sprout@cpan.org>
Sun, 30 Jun 2013 21:51:37 +0000 (14:51 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 26 Jul 2013 06:48:02 +0000 (23:48 -0700)
commitd2440203227a535b62a2078d898d0bd993ceac78
tree76fec5bb7b07aea0f265664c3d4309b83c442f8b
parent08f3c4220c9fd172aa553652547dfbfac485dae7
Make sub(){42} return a mutable value

But only make it do so in lvalue context.  This will be just as fast
in true rvalue context.  In either case, it is still inlined.

This makes sub () { 42 } and sub () { return 42 } do the same thing.

It also means that sub () { '-'x75 } reverts back to returning a muta-
ble value, the way it did in 5.16.  From now on, tweaks to constant
folding will no longer affect the mutability of the return value of a
nullary function.

‘use constant’ is unaffected.  It still returns read-only values.

This was brought up in ticket #109744.
op.c
t/op/sub.t