Tassilo von Parseval wrote:
I sent this to Tassilo a while ago ... meant to cc the list.
If you're replying to a usenet post you generally want 'Reply', but if it's a mailing list you generally want 'Reply to All' :-)
How does it get done in perl-space ?
It's almost impossible. The problem is that the pointer to PL_sv_yes is destroyed once you allow an assignment:
use Inline C => <<'EOC';
SV* yes () { return &PL_sv_yes; }
void get_yes (SV *a) {
if (a == &PL_sv_yes) printf("Received PL_sv_yes\n");
else
printf("Something else\n");
}
EOC
get_yes(yes());
$a = yes();
get_yes($a);
__END__
Received PL_sv_yes
Something else
That's because an assignment in the end means that Perl_sv_setsv_flags is called and that wont preserve the pointer.
Nice demo.
When I do a Devel::Peek::Dump($a) and a Devel::Peek::Dump(yes()), I find the only essential difference is in the readonly flag, and the refcount.
I was about to test further by setting $a's readonly flag (trivial) and changing the refcount from 1 to 2147483647 - but I realised that I don't know how to set the refcount to 2147483647 - unless I call SvREFCNT_inc() 2147483646 times - which a more adventurous spirit might have tried, but I did not.
It has been quite an education - and will continue to be so, while I poke around and test to see if I really *do* understand what you have been telling me.
Thanks Tassilo.
Cheers, Rob