in reply to RFC Magic::Attach

Nice work. However, the "other modules might clobber you if they're not careful" part is a worry to me. When we implemented Pixie::Info as a way of storing out of band data for Pixie (we need it so that Pixie can manage objects in memory without having to alter anything 'visible' -- no invading of hashes for us...) we came to the conclusion that the very clobberability of '~' magic (and some of the special case semantics that are automatically associated with it mean that *not* clobbering '~' magic is hard work) meant we should use a different magic symbol, after all, there's over 200 available, we chose chr(155).

What we *should* have done, of course, is to hang a hash off the object and hang our out of band information in the 'Pixie' slot...

Replies are listed 'Best First'.
Re: Re: RFC Magic::Attach
by shotgunefx (Parson) on Jan 21, 2003 at 08:28 UTC
    Yes it worries me too. sv_unmagic() on '~' removes all '~' magic entries currently (Which is why the current implemenation does not call it). I wonder if there would be any way or (where) to determine what modules exist that use internal magic. I would think there are not too many. The only one I know of is Devel::WeakRef and Pixie.

    I don't mind taking my own magic entry but worry about clashes with future versions of Perl 5.* and of course other modules developers.

    -Lee

    "To be civilized is to deny one's nature."
      Just announce that you're grabbing a magic sigil on p5p, explaining why (that's what I did). Who knows, make it general enough and it might end up in the core.
        Thanks. I actually saw your post to perl5-porters which clued me in on the sv_unmagic issue.

        -Lee

        "To be civilized is to deny one's nature."
Re: Re: RFC Magic::Attach
by shotgunefx (Parson) on Jan 22, 2003 at 09:23 UTC
    For the moment I am going to stick with '~' though it issues a warning if it finds any other '~' magic. (I'm now prefixing names)
    Data::Attach Found a '~' magic that is not ours (EVIL ATTACH). Possibl +e conflict with (Dat:attachtest)


    -Lee

    "To be civilized is to deny one's nature."