Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: calling subs using references.

by rinceWind (Monsignor)
on May 22, 2007 at 14:46 UTC ( [id://616780]=note: print w/replies, xml ) Need Help??


in reply to calling subs using references.

I have a niggle. There's a misquoted idiom in your constructor. The line is:

return bless {}, $caller || ref($caller);

If $caller is false, there's no way it can be a reference. The idiom you've misquoted has the or round the other way, which allows the user to pass in an existing object from which you derive the package name.

In practice, nobody's ever going to call new on an existing object. There's thus no need to document and test for this special case, just code it as:

return bless {}, $caller;

--
wetware hacker
(Qualified NLP Practitioner and Hypnotherapist)

Log In?
Username:
Password:

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

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

    No recent polls found