in reply to Re: XS and preserving magic
in thread XS and preserving magic
Thanks Elian, I thought of that but my grasp of internals sucks. I found a module that did 90% of what I wanted (Devel::WeakRef). I stared at it till I could grok it and then modified it. I do think I am starting to get a bit of a handle on things though. :)
When I didn't see any takers for my question (I'm impatient dammit. Problems like this I have to keep going till I win or I forget where I was), I grepped through the source of 5.8 and 5.6.1 and found the problem. There is no such flag as far as I can tell.
It'is a bug in perlguts documentation for 5.6.1.
Looking at the code for Perl_sv_magic and the same portion in the 5.8 source, the 5.8 source is commented.
/* sv_magic() refuses to add a magic of the same 'how' as an
existing one
*/ARGG!!!!
I couldn't find the flag because there was none. In 5.8 you are supposed to use Perl_magicext which is for this purpose. I stole it and some defines and so far works great in 5.6.1. Renamed it to avoid clashes.
It potentially does have some very interesting applications.
I suppose I could add it so the same ref can't be attached twice and it only called as $self->method then you could have some really private objects (If you are into such things.)
Personally I think it's nice to be able to attach some private info without having to tie or bless something or otherwise muddle up the caller.
-Lee
"To be civilized is to deny one's nature."