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.
  • The right way to do this would be Replace Conditional With Polymorphism… that is, if feasible/sensible, wrap the objects in other objects which all have a stringify method that delegates to the right method in the wrapped object.

    But doing it for just this one instance, of course, is way too much effort.

    And I find that can is often the wrong tool when I’m just trying to do something, regardless of how it gets done. Usually, eval is better suited to that job, although in this case it is so unw

    • You know, that might make an interesting generic class. Something which, given a list of classes, can automatically set up common delegate methods to allow the language to work out the logic rather than the programmer. It reminds me of a few programmers I've spoken with who don't seem to understand the value of how many OO languages can properly dispatch on signature to identically named methods. Pushing conditional logic into the language's hands rather than the programmer's is definitely the way to go.

      • And matching on the signature alone is pretty rudimentary. Real magic happens when you do actual structural matching, à la Haskell f.ex.