On Tue, Jun 14, 2005 at 12:33:34PM +0000, Ingo Blechschmidt wrote:
: Hi,
:
: sub proxy () is rw {
: return new Proxy:
: FETCH => { 42 },
: STORE => -> $new { 23 };
: }
:
: say proxy(); # 42
: say proxy() = 40; # 40, 23, or 42?
:
: Currently I think the last line should output 40, consider:
:
: sub innocent_sub ($var is copy) {
: my $foo = ($var = 40);
: # Do something with $foo, relying on $foo being 40.
: }
:
: { my $x = "does not matter"; innocent_sub $x }
: # Works
:
: { my $x := proxy(); innocent_sub $x }
: # Would break if (proxy() = 40) would not return 40.
:
: But I can argue that the return value of Proxy object should
: be the return value of the code given by FETCH in the Proxy
: object construction, too...
:
: Opinions?
The intention is that lvalue subs behave in all respects as if they
were variables. So consider what
say $nonproxy = 40;
should do. This also extends to other operations than assignment:
temp $foo.bar() = 40;
or the very-nearly-Software-Transactional-Memory-oriented:
let $object.attribute() = 40; # hope this sticks...
Larry
Thread Previous