Dave Mitchell <[EMAIL PROTECTED]> wrote:
:On Fri, Jun 10, 2005 at 11:04:36AM +0100, Dave Mitchell wrote:
:> I'm vaguely assuming that for tieing, during localization you would *copy*
:> the magic; then at restore time you just ditch any magic on the new SV,
:> and stick the old SV back into the typeglob with its current magic
:> intact. ie
:
:I now have a working patch that does just that

Cool.

:--- ./t/op/local.t     Mon Jun 13 20:18:48 2005
:+++ ./t/op/local.t     Mon Jun 13 20:26:54 2005
:@@ -268,8 +268,9 @@ eval { for ($1) { local $_ = 1 } };
: print "not " if $@ !~ /Modification of a read-only value attempted/;
: print "ok 77\n";
: 
:+# make sure $1 is still read-only
: eval { for ($1) { local $_ = 1 } };
:-print "not " if $@;
:+print "not " if $@ !~ /Modification of a read-only value attempted/;
: print "ok 78\n";

I may be misreading it, but I think here the C< local $_ > retains
the $1 magicalness because it is container magic?

If so, that's a shame - we should really be able to use C< local $_ >
to get an unadorned scalar: the sledgehammer C< local *_ > is no
substitute for that.

In my mind, the magic "belongs" to $1, and has been "lent" to $_
by aliasing. The localisation should be breaking the alias, and
that should allow $_ to rid itself of the magic shackles.

If C< local $1 > were allowed, that'd be different - now it is the
magic container itself we are localising.

Apologies if I've got the wrong end of this.

Hugo

Reply via email to