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

  • inspiration

    _why: "when you don't create things, you become defined by your tastes rather than ability. your tastes only narrow & exclude people. so create."

  • minimal openid consumer

    Here's a minimal OpenID consumer using the Ruby OpenID libraries. (Their included examples only contain Rails spew.) This example is useful for…

  • weird type flexibility (ruby-openid and chr)

    So a couple of others have had trouble with the ruby-openid library. The problem is that starting up the whole thing with:…

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