Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: Object singleton method

by brian_d_foy (Abbot)
on Apr 22, 2008 at 16:36 UTC ( #682211=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Object singleton method
in thread Object singleton method

Oh, you're not looking for singleton objects. You're looking for objects of the same class to have the same method names but do different things based on the object. Singletons aren't about the method names but how many objects there actually are.

You have a bit of an XY Problem here since we don't know what you are trying to solve. What are you trying to accomplish (rather than how you are trying to do it)?

If you want the objects to start off as the same class and specialize later, look at Class::Prototyped. Each object can start the same, but then gain or replace methods (called "slots" in prototype programming). Randal's CGI::Prototype stufff is based on this and once you get used to the idea it's very nice to work with given an appropriate problem.

Good luck, :)

--
brian d foy <brian@stonehenge.com>
Subscribe to The Perl Review


Comment on Re^3: Object singleton method
Re^4: Object singleton method
by Arunbear (Parson) on Apr 22, 2008 at 21:35 UTC
    In Ruby's version of prototype based programming, slots are called singleton methods - this is perhaps what the OP was referring to.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2014-12-28 16:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (182 votes), past polls