Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: Class::InsideOut - yet another riff on inside out objects.

by Aristotle (Chancellor)
on Dec 19, 2002 at 22:07 UTC ( [id://221266]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Class::InsideOut - yet another riff on inside out objects.
in thread Class::InsideOut - yet another riff on inside out objects.

I think I have something for you.

I've been raking my brain for ways of having the attribute routine somehow register something like a hook whose call is delayed so that by the time the hook is triggered, the hash is on the pad. I hadn't been able to come up with any approach so far.

The idea I just came up with is simple: tie. :-)

Tie the attribute hash temporarily. The first access to it will trigger a call whence PadWalker can hopefully locate it. The rest is details - create an accessor closure in the appropriate package and untie the hash.

Unfortunately I'm not of much help since 5.6.1 manages the pads differently and I can't write test code to confirm this. But you should be able to make something of it.

Makeshifts last the longest.

  • Comment on Re^3: Class::InsideOut - yet another riff on inside out objects.

Replies are listed 'Best First'.
Re^4: Class::InsideOut - yet another riff on inside out objects.
by adrianh (Chancellor) on Dec 22, 2002 at 01:36 UTC

    Ah. Unfortunately, not that sneaky after all. Consider:

    { package Test; use base qw(Class::InsideOut); sub new { bless [], shift }; my %foo : Field; };

    %foo might now be tied but, since there is no way to access it, no magical attribute generation can happen :-(

    Only works if you need to access the hash elsewhere in the same class - which may not always happen.

      Argh. Of course. I'm starting to feel a bit stupid. I should get 5.8 myself and start playing around so I don't miss the obvious loopholes in my ideas.

      At any rate it looks as though we'll have to get out the heavy hitter to crush this one..

      Makeshifts last the longest.

        I've never used any of the B:: modules in anger before - maybe if I get some free time over the Crimble break I'll give it a whirl.

Re^4: Class::InsideOut - yet another riff on inside out objects.
by adrianh (Chancellor) on Dec 20, 2002 at 14:23 UTC
    The idea I eventually came up with is simple: tie.

    Sneaky. Like it. Can't see a reason why it wouldn't work off the top of my head. Might give it a whirl this weekend when I have some more time :-)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2024-04-23 09:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found