[EMAIL PROTECTED] wrote:
> :+# 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?

Localisation retains magic, and $_ is an alias for $1 to it has its
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.

But "my $_" can be.

> 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.

That would be a huge change, I think.

Note also that readonlyness is preserved on localized magic variables
since change 20479. See the bug discussion :
    https://rt.perl.org/rt3/index.html?q=23141

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

You can localize *1 :)

-- 
The problem with being consistent is that there are lots of ways to be
consistent, and they're all inconsistent with each other.
    -- Larry Wall in p6l

Reply via email to