Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^5: Simple inheritance question

by webfiend (Vicar)
on Apr 23, 2010 at 17:12 UTC ( #836570=note: print w/replies, xml ) Need Help??


in reply to Re^4: Simple inheritance question
in thread Simple inheritance question

Glad you got the solution you needed. I was a little unclear on the original question. I also think it's interesting that One doesn't need a constructor in the object solution. It makes sense, considering that a One is never instantiated. I didn't realize that Perl's package handling let's you "inherit" from a package that isn't actually a class.

We learn something every day if we give ourselves a chance.

Replies are listed 'Best First'.
Re^6: Simple inheritance question
by chromatic (Archbishop) on Apr 23, 2010 at 19:36 UTC
    I didn't realize that Perl's package handling let's you "inherit" from a package that isn't actually a class.

    There's no effective difference between a package and a class or a function and a method inside Perl 5. The internals don't care. If you treat something like a class name (by using it as an invocant), Perl 5 will use that package's namespace to find the destination method. Any reference blessed into a package will use that package's namespace to find its destination methods.

    Those packages don't even have to exist for Perl 5 to attempt to dispatch to them as invocants, but you will get dispatch errors if they don't.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://836570]
help
Chatterbox?
[Corion]: So Hyperboria is an envrypted, decentralized IPv6 mesh network. I'm interested and want to look how good coverage is in my area. But the API for querying Hyperboria is only reachable over Hyperboria itself. Thanks but no thanks.

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2017-06-23 07:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (536 votes). Check out past polls.