Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: Garbage collected class attributes with inside out classes.

by eric256 (Parson)
on Mar 02, 2007 at 00:22 UTC ( [id://602807]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Garbage collected class attributes with inside out classes.
in thread Garbage collected class attributes with inside out classes.

I think I understand now. So you are talking about having class attributes along side the instance attributes? If that is the case wouldn't you want the class attributes to exist until the program terminated in case you created a new instance after all the others where destroyed?

This my ($other_ident) = keys %example_hash_of; is confusing me, what does that do? It would seem that its just grabbing the first key in the hash regardless of what it is.

I have the distinct feeling I'm confusing the trees with the forest here, but I'm also determined to understand!


___________
Eric Hodges

Replies are listed 'Best First'.
Re^4: Garbage collected class attributes with inside out classes.
by kyle (Abbot) on Mar 02, 2007 at 02:55 UTC

    wouldn't you want the class attributes to exist until the program terminated in case you created a new instance after all the others where destroyed?

    In many cases, I'd expect that to be true, yes. Part of my background for this, however, is that one of these class attributes holds a large data structure that I don't want to hold in memory. There could be other reasons for wanting one thing shared by all instances that you also want to deallocate when there are no more instances.

    It would seem that its just grabbing the first key in the hash regardless of what it is.

    Yes, that's exactly what it does. It finds any other instance of the same class. if there is no other instance, $other_ident will be undef. If there is some other instance, I take a copy of that instance's class attribute reference. Since they all have the same reference, it doesn't matter which one I get.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-03-28 19:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found