develooper Front page | perl.perl5.porters | Postings from March 2006

Re: how should %^H work with lexical pramas

Thread Previous | Thread Next
David Nicol
March 30, 2006 11:10
Re: how should %^H work with lexical pramas
Message ID:
On 3/30/06, demerphq <> wrote:
> Im still curious about the case of
>    $^H{dooot}=9*3 if $condition;
> IE, setting the hint NOT in a begin block?
> Yves

Right.  What do you think should happen?

Currently the behaviour is undefined and therefore does not need to be tested.

One possibility is that what would happen is the hints hash, if you
read it, will give you
what you last put into it, but the hints mechanism makes no guarantee
that whatever
was to be affected by the hint will be changed.

If a magic could be added by the pragma so the pragma can gets notified and
re-do its thing when the hints it cares about get changed, that would be a good
thing for a pragma to do.  I believe any number of magics can be added there,
so after the nature of the hints hash settles down, registering the
hook in a pragam
with the hints hash for change notifications will be non-hard; also
that the tests
for such things working would be a later, different test.

One simple way to both do the hooks and to define some trivially
testable semantics
would be to declare a name space for the hook when the hints hash gets
stored to.
in Yves' code, when $condition is true, &PRAGMATA::STORE_HOOK::doot would get
called, perhaps with a reference to the underlying writable %^H that
exists at that
level and the value.  When that subroutine doesn't exist, the hash
gets modified, but
the modification is only visible in the current scope.

So what do you do when you want to effect a global change to a hint?

David L Nicol
"the opportunity of making good with a hard undertaking - one that had
been held impossible of realization - would be a strong asset to the
firm's reputation" -- William Russell, 1860

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