Subject: | set_prototype() and get-magic |
Date: | Tue, 01 Nov 2011 11:28:41 +1100 |
To: | bug-Scalar-List-Utils [...] rt.cpan.org |
From: | Kevin Ryde <user42 [...] zip.com.au> |
Nosing around ListUtil.xs set_prototype() I saw
if (SvROK(subref)) {
without running get-magic on that subref, it seems. Should it do the
magic so a tied scalar for the coderef will work, such as foo.pl below
which gets
Scalar::Util 1.2303
set_prototype: not a reference at /tmp/foo.pl line 25.
where I though it might run the FETCH of MyTie and act on the \&my_subr
established there.
#!/usr/bin/perl -w
use strict;
use Scalar::Util;
print "Scalar::Util $Scalar::Util::VERSION\n";
{
package MyTie;
sub TIESCALAR {
my $class = shift;
return bless {@_}, $class;
}
sub FETCH {
return \&my_subr;
}
sub my_subr {
}
}
my $foo;
tie $foo, 'MyTie';
# print $foo,"\n";
&Scalar::Util::set_prototype ($foo, '$$');
print prototype($foo),"\n";
exit 0;