Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Can you give an example where this makes sense?

When one wants to use such functions without instantiating an object first. But I guess one can use class methods (as per your definition) and *make sure* to consume the 1st param which will be the classname.

I think this might sabotage many patterns like sub-classing...

You mean because staticfunc will not be seen in a sub-class unless you do both: use base 'Class'; and use Class; ? I guess yes that's a problem.

I took a quick glimpse into static functions for C++ and Java and they look very much like class methods to me.

Yes, except that they don't mess with the parameters to provide a classname.

Do you suggest that there is no use-case for staticfunc(), but instead convert it into a class method and consume the 1st param, in order to provide accessing it without instantiation first? OK, fine. But I think it is important to provide access to such methods which do not need the state and can be called without instantiating a dummy object first which will be of no use whatsoever. So I think what I posted is useful, but I can edit it to use class methods when this dialogue ends.

bw, bliako


In reply to Re^3: Procedural vs OOP modules by bliako
in thread Procedural vs OOP modules by Bod

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-23 20:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found