Re: [rt.cpan.org #125472] error with coderefs passes as scalar args
[email protected] (huck) Tue, 03 Jul 2018 12:27:36 -0500
| Newsgroups | perl.tcltk |
|---|---|
| Message-ID | <[email protected]> |
At 03:07 AM 7/3/2018, you wrote:
><URL: https://rt.cpan.org/Ticket/Display.html?id=125472 >
>
>we very much appreciate the effort;
>
>unclear for me - why $sub1 and $sub2 will have same slot for this statement,
>$interp->call('if,'1',$sub1,$sub2);
>
>there is:
>...
># stringify sub, becomes "CODE(0x######)" in ::perl namespace
>
>so $sub1 and $sub2 will recieve different slots in %anon_refs hash
in the v1.05 code
$current_r will be set once at the top of the loop by
my $current_r = join ' ', grep {defined} grep {!ref} @args;
so it will be 'if 1'
and is passed into create_tcl_sub() in the 4th parm where it becomes $rname
and $anon_refs gets set with
$anon_refs{$rname} = bless [\$sub, $interp], 'Tcl::Code';
so both calls get sequentially created into the same $anon_refs slot
$anon_refs{'if 1'}
And before the second gets assigned Tcl::Code::DESTROY is triggered
on the first.
>all in all, if you'll find a correct solution - nice. if isn't -
>also not bad. for mee, we already have too much code for the case,
>which I would prefer to be simplier.
This kind of reference tracking is never simple, i have tried to keep
it as simple as it needs to be.
>also, what a need for
>sub _anon_refs_cheat { return \%anon_refs;}
>
>?
it serves to expose %anon_refs to external programs so they can test what has
been done to it by the process in the module. I often do this to be
able to test that things are working right without having to add
other exposing code to the primary module.
>can we switch to mailing list?
i think i got subscribed, so this is cc'd to the list.
for those first seeing this on the list there is historical background at
https://rt.cpan.org/Public/Bug/Display.html?id=125472