Dan wrote:
> At 12:50 PM 9/4/2001 -0500, Garrett Goebel wrote:
> >
> >So deleting it
> >would remove it from the scratchpad of &incr. But I would guess that
> >future calls to &incr would have to autovify $x in the scratchpad and
> >start incrementing it from 0. I.e., ignoring a package $x if it exists. I
> >could see people prefering it either way...
>
> Folks might also want that to then refer to the $x in the enclosing scope.
> Don't think that's going to happen, though. (Lots and lots of runtime
> overhead in that case)
I agree (both that people might want that, and that it's probably not
going to happen ;-)
> I can see allowing read/write/change/iterate access (possibly
> enforcing types when writing) but not delete. That opens up a
> number of cans of worms I'd rather stay closed for now.
Why not C<delete>? It merely requires that the internals equivalent of:
sub LEXICAL::SCALAR::FETCH ($varname) {
$scalar_ref = caller().{MY}{$varname};
return $$scalar_ref;
}
sub LEXICAL::SCALAR::STORE ($varname, $newval) {
$scalar_ref = caller().{MY}{$varname};
$$scalar_ref = $newval;
}
becomes:
sub LEXICAL::SCALAR::FETCH ($varname) {
$scalar_ref = caller().{MY}{$varname}
or throw "lexical $varname no longer in scope";
return $$scalar_ref;
}
sub LEXICAL::SCALAR::STORE ($varname, $newval) {
$scalar_ref = caller().{MY}{$varname}
or throw "lexical $varname no longer in scope";
$$scalar_ref = $newval;
}
I don't understand why you think that's particularly wormy?
Damian