Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Temporarily disabling overloaded operations.

by BrowserUk (Pope)
on Sep 15, 2003 at 06:45 UTC ( #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.


Comment on Re: Temporarily disabling overloaded operations.
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2014-07-26 17:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (178 votes), past polls