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

  • dremel

    They published a paper on Dremel, my favorite previously-unpublished tool from the Google toolchest. Greg Linden discusses it: "[...] it is capable…

  • more on synonyms

    Before Chrome, this is what I spent much of my Google career working on.

  • google ime

    Japanophiles might be interested to learn that Google released a Japanese IME. IME is the sort of NLP problem that Google is nearly uniquely…

  • 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.