Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re^2: Tkx after coderef problem

by huck (Parson)
on Jun 04, 2018 at 16:32 UTC ( #1215859=note: print w/replies, xml ) Need Help??

in reply to Re: Tkx after coderef problem
in thread Tkx after coderef problem

Thanks, i did see that, but at the time i skipped it because i wasnt involved in the '+' format

Now looking again i find i need to remember my $interp = Tkx::i::interp(); as at once point i wondered how to do that, but settled on using Tkx::info rather than the $interp->call('info','commands','::perl::*') i had seen somewhere(edit:add

This issue is only related to after, and involves code modified in code disposal works, only 1 question remains; perl::Eval now in Tcl__new and added in the version 1.03 release as of 2016-02-20 I suspect someone (vadrer?) saw that the commands-table/$anon_refs were filling up with address to single use anon-subrefs from the "after command" and wanted to clean them up. His approach while admirable hosed calls where the subref passed into after was not a single use anon-subref (or of the [$coderef] variety, since those generated a single use anon coderef too) because it prematurely discarded them from the Commands-table/$anon_refs.

While i have faith in my patch, and think it will solve the introduced problem while retaining the needed "code disposal", patching code is never as simple as it looks. What it does is introduce a "weakened" version of the coderef in the anon_refs table under the $tclname key it used to have pre v1.03 and copies that entry into a "strong" newer $current_r style name when needed, so it can be used in the "consolidated" $anon_refs that get scheduled for deletion. Now further "after" calls will be able to create their own consolidated entries for deletion but since the refcount will be greater than one for a "static" coderef since there will be multiple copies in multiple "consolidated" $anon_refs, when _code_disposal is called the Tcl::Code::DESTROY that purges that entry from the command table wont be invoked until the last consolidated $anon_refs entry has been destroyed.

Since code disposal is only invoked on "after" calls, for non-after calls i dispose of the weakened $tclname key right away, and those coderefs continue to live in the commands-table/$anon_refs "forever", just like they used to pre v1.03 and still currently do.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1215859]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2020-07-03 22:26 GMT
Find Nodes?
    Voting Booth?

    No recent polls found