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

Re: Temporarily disabling overloaded operations.

by BrowserUk (Patriarch)
on Sep 15, 2003 at 06:45 UTC ( [id://291496]=note: print w/replies, xml ) Need Help??


in reply to Temporarily disabling overloaded operations.

As a "matter arising" from my playing with the above, but of little real import

If my object is internally implemented using a single scalar value, and I use the IOO method of using the blessed ref representing the object as a key into a my'd hash, then I need 3 things. The hash (%hash), the scalar holding my data ($data), and a blessed ref ($self);

package mypackage; my %hash; sub new { my $self = bless \1, $_[0]; $hash{ $self } = 'Initial data'; return $self; }

In the above, I am using \1 just to get a unique scalar ref which I can bless. I'm then using this as the key through which to access another scalar (the hash value) which is going to hold my actual data.

Now (my twisted type of) logic says, if I already have a scalar to hold my data, then I don't need to create another just to get my blessed ref, I could just bless a reference to the data. The problem is, you can't take a reference to a hash element until you have a key, and I want to use the reference as the key. Catch-22

Can I have my chicken lay an egg? Can I generate a self-addressing stringified reference?

The "mypackage=SCALAR()" bit is constant, so I would need to vary the hex value within the brackets until the address of the scalar allocated for the hash generated matched the hex value I generated. Is that possible? In my lifetime:)


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
If I understand your problem, I can solve it! Of course, the same can be said for you.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2024-03-29 08:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found