Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Re: Re: Re: RFC Magic::Attach

by shotgunefx (Parson)
on Jan 21, 2003 at 04:35 UTC ( [id://228582]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: RFC Magic::Attach
in thread RFC Magic::Attach

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."

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: RFC Magic::Attach
by John M. Dlugosz (Monsignor) on Jan 21, 2003 at 06:32 UTC
    I agree it's too limited to be called Magic::Attach. That would be a good name for a helper module used to implement such a thing, something you wish you had instead of having to write in XS.

    The use of the ~ table is meerly an implementation detail. What the module does is attach named attributes to a value at run time. It should be named for its public interface and purpose, not for its implementation details. (Save that name for a concrete implementation when the same interface is implemented multiple ways based on the situation).

    This concept is what Perl 6 calls "Properties", and LISP also calls it properties. It's different from the existing Perl attributes or attribs.

    —John

      If I add the callback functionality, perhaps it will be worthy of the name. But even then I think the name should be somewhat generic because it is not intended to be a property or attribute, simply the binding of pieces of data. What you do with it on the other hand...

      While I understand the "magic" part is simply an implementation detail, it might be worth having simply for the fact that when something goes wrong, something along these lines is bound to break in strange ways where most people would never think to look.

      BTW, What is the best place to get up to speed on Perl 6. I read the exgenesis and apocalypses but I'm sure much has changed. Any good overviews of the current state?

      -Lee

      "To be civilized is to deny one's nature."
Re: Re: Re: Re: Re: RFC Magic::Attach
by theorbtwo (Prior) on Jan 21, 2003 at 04:48 UTC

    Hm. The on the one hand, yes, from this table. On the other hand, it feels like it should be possible to make a half-tied variable, which invokes a perl sub when stored into, but has no overhead (and does nothing special) when gotten from (or vice-versa). The docs confuse me.


    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).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://228582]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-19 21:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found