Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Changing the core (Score:3, Insightful)

    by acme (189) on 2003.03.23 21:37 (#18233) Homepage Journal
    Some of the neatest Ruby examples I've seen add methods or modify methods of the core classes. It's certainly neat and pretty clean. But what happens when multiple authors of the modules you happen to be using all muck about with the core in different, slightly incompatible ways?
    • It all goes to hell =)

      Generally, if you're modifying a class that isn't yours then you
      should only be adding stuff that's really generic. For example,
      a binary search to Array.

      Otherwise, you should be making your own Array subclass.

      I wouldn't be surprised if someone's already implemented
      a bsearch (in fact, I think Hal Fulton has one in "The Ruby Way").
      Ideally someone would be collecting these useful generics into
      a package, somewhere. Think List::Util =)

      But, yeah, it can go to hell.
      --
        ---ict / Spoon
  • I think it's going to be possible to create multimethods in Perl 6 that'll allow you to write smart comparators along the lines of the smart match operator, which should in turn allow for you to write a nicely generic binary search method on Array.

    Doesn't help with Perl 5 though.