Evan Martin (evan) wrote in evan_tech,
Evan Martin


This bug makes me a little sad. From one of the patches for fixing:
- @string = (str.string rescue str)
+ @string = str.respond_to?(:string) ? str.string : str

The problem is that the former method uses an exception handler, and when an exception is generated it includes a backtrace, and this particular bit of code gets called with very deep call stacks, so that bit of code ends up being expensive.

I think the fixed code better expresses what the code was trying to do -- the former one could imaginably produce strange errors if you had, for example, a typo in an object's "string" method -- but the underlying problem is the sort of leaky abstraction that endemic to programming in general and always disappoints me a bit with the state of our art.
Tags: ruby

  • your vcs sucks

    I've been hacking on some Haskell stuff lately that's all managed in darcs and it's reminded me of an observation I made over two years ago now (see…

  • perl people, explain your language to me

    Every time I use perl I feel mildly positive about it right up until I encounter CPAN. I've never managed to make CPAN work, despite the multitude of…

  • dns attack of doom

    If I've learned anything from the new Kaminsky DNS attack, it's that if you want to keep something a secret while disclosing to a trusted subset of…

  • Post a new comment


    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.