in reply to RFC Magic::Attach

DOCUMENTATION!

After reading though the examples several times, I think I understand more or less what this does. I shouldn't have to do that.

I vaugely know what magic is, and what the ~ magic vtable is. I had to read over the samples three times before I understood what you're doing there.

It doesn't help that the ~ magic vtable has nothing to do with the "traditional" meaning of magic -- that is, it's never automaticly called.

I wonder how difficult it would be to allow you to set other types of magic to a perl sub, to be able to create partialy-tied things, and other wierd stuff.

Oh, and I think SvREFCNT can be gotten from several other places as well.


Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

Replies are listed 'Best First'.
Re: Re: RFC Magic::Attach
by shotgunefx (Parson) on Jan 21, 2003 at 03:52 UTC
    Point taken. I was intending to document it better after the feedback from this post (I assume I'll be making much changes)

    "It doesn't help that the ~ magic vtable has nothing to do with the "traditional" meaning of magic -- that is, it's never automaticly called."

    Actually if callbacks are setup they are automatically called. The only callback I am installing is for the freeing of the SV so that it won't leak the attached reference.

    I do plan on another module to allow user-defined callbacks but I didn't want to get over my head. My grasp of things internal is still less than *COUGH* um, firm.

    I added SvREFCNT for some additional tests I am going to implement. I didn't want to require any prerequisites for the tests alone.

    Thanks,
    -Lee

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

      Cool. All sounds good, though I wouldn't call it Magic::Attach, then... try Magic::ArbitraryData, perhaps? Magic::Attach::Anything? Magic::Tilde? Anyway, I'd save Magic::Attach for the other module, the one that attaches more traditional types of magic to a var.


      Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

        Perhaps Magic::Bind?

        As far as attaching other types of magic , I don't know if that's a good thing. From how I read it, outside of '~' and 'U', none of the other types of magic are supposed to be used outside of the core, though anyone feel free to correct me.
        mg_type MGVTBL Type of magic ------- ------ ---------------------------- \0 vtbl_sv Special scalar variable A vtbl_amagic %OVERLOAD hash a vtbl_amagicelem %OVERLOAD hash element c (none) Holds overload table (AMT) on stash B vtbl_bm Boyer-Moore (fast string search) D vtbl_regdata Regex match position data (@+ and @- +vars) d vtbl_regdatum Regex match position data element E vtbl_env %ENV hash e vtbl_envelem %ENV hash element f vtbl_fm Formline ('compiled' format) g vtbl_mglob m//g target / study()ed string I vtbl_isa @ISA array i vtbl_isaelem @ISA array element k vtbl_nkeys scalar(keys()) lvalue L (none) Debugger %_<filename l vtbl_dbline Debugger %_<filename element o vtbl_collxfrm Locale transformation P vtbl_pack Tied array or hash p vtbl_packelem Tied array or hash element q vtbl_packelem Tied scalar or handle S vtbl_sig %SIG hash s vtbl_sigelem %SIG hash element t vtbl_taint Taintedness U vtbl_uvar Available for use by extensions v vtbl_vec vec() lvalue x vtbl_substr substr() lvalue y vtbl_defelem Shadow "foreach" iterator variable / smart parameter vivification * vtbl_glob GV (typeglob) # vtbl_arylen Array length ($#ary) . vtbl_pos pos() lvalue ~ (none) Available for use by extensions


        -Lee

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