Previous Entry Share Next Entry
12:28 pm, 3 Mar 08


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.