develooper Front page | perl.perl5.porters | Postings from May 2010

Re: [perl #6813] tie() magic upsets stack (can't last() outside ofblock)

Thread Previous | Thread Next
Dave Mitchell
May 3, 2010 09:28
Re: [perl #6813] tie() magic upsets stack (can't last() outside ofblock)
Message ID:
On Thu, Apr 29, 2010 at 10:51:26AM -0700, Eric Brine via RT wrote:
> A simpler demonstration:
> ---- BEGIN CODE ----
> #!/usr/bin/env perl
> use strict;
> use warnings;
> {
>    package Tie;
>    sub TIESCALAR { return bless({}, shift); }
>    sub STORE { next; }
> }
> tie my $x, Tie::;
> { tied($x)->STORE(123); }  # warns, but works
> { $x = 123;             }  # warns and dies
> ---- END CODE ----

I think this behaviour is correct. Tied method calls shouldn't consider
any context outside the method call itself. After all, the tied action
could have been invoked from almost anywhere, including somewhere deep
within XS code.

I also think the behaviour is deliberate. Magic method calls are run on a
new set of stacks, and while die etc will pop back across multiple
context stacks, pp_next etc only look at the current stack.

Britain, Britain, Britain! Discovered by Sir Henry Britain in
sixteen-oh-ten. Sold to Germany a year later for a pfennig and the promise
of a kiss. Destroyed in eighteen thirty-forty two, and rebuilt a week
later by a man. This we know. Hello. But what of the people of Britain?
Who they? What do? And why?   -- "Little Britain"

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