Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^3: Calling module function from within a blessed module

by dsheroh (Monsignor)
on Jan 03, 2021 at 12:45 UTC ( #11126196=note: print w/replies, xml ) Need Help??


in reply to Re^2: Calling module function from within a blessed module
in thread Calling module function from within a blessed module

The reason why you generally shouldn't use the one-argument version of bless is because it makes subclassing more difficult.

If you have two classes, Parent and Child, and Parent uses bless {}, $_[0];, then Child can simply inherit Parent's new (or other constructor) and Child->new() will Just WorkTM.

If Parent uses one-argument bless, then it will always create a Parent object, and Child will have to override the constructor (either writing a completely new constructor, or calling Parent's constructor and re-blessing the result before returning it).

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2021-04-10 14:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?