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

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
That helps with your own data types. But since most programs just use the default data types, it still takes more work in Perl to define a generic min function that works across strings and numbers.

And, to tell the truth, in Perl 5 you can already use overload to define a comparison function and then use a fairly generic min function. Of course people don't actually use this much in practice. For many good reasons. Most people haven't learned what they can do with overload. Also it is a fair amount of work (Perl 5 doesn't have multiple dispatch to help). And using overload like this in shared Perl code violates the principle of not surprising your maintenance programmer. And finally because for most programs it is more convenient to use default data types.

That said, the first bug I found in Ruby was that if you defined a subclass of String that is exactly like a String but it compares in reverse, the built-in sort method from Comparable will ignore your comparison and use the normal string comparison. I was told that this bug is due to a deliberate optimization. I just tested it. The bug is still there. :-(

So even having a clean design doesn't help you if you break your own design for performance reasons.


In reply to Re^4: I think Perl ruined me as a programmer by tilly
in thread I think Perl ruined me as a programmer by Petras

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 examining the Monastery: (4)
As of 2024-04-24 03:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found