[Borges-users] RenderNotification considered harmful
Слепнев Владимир
slepnev_v at rambler.ru
Fri Apr 30 04:25:00 EDT 2004
Maybe I'm wrong in posting patch suggestions here? Maybe there should
be some mechanism of Eric approving patches or rejecting them? I just
don't know.
I have removed the RenderNotification class from my Borges copy.
Rationale: Ruby's raise/rescue mechanism is intended for error
handling, not control flow. (What if someone does 'rescue Exception'?)
For control flow, Ruby has throw/catch (which isn't subject to
'rescue', but honors 'ensure'). Also, throw/catch is used with a
string or symbol, while raise/rescue uses an exception class; having a
dummy exception class smells of Java to me. Also, the syntax for catch
is in our case simpler than the syntax for rescue, execution just
continues from the end of the catch block:
def render
catch :RenderNotification do
[snip]
end
end
(we also need to throw :RenderNotification somewhere =)
(Actually, this mechanism is a little flawed too. I stumbled upon this
when trying to use DBI. It has a connect method which takes a block,
and disconnects after the block finishes; wrapping a
Borges::Controller#call in this doesn't work, apparently because DBI
uses rescue/ensure to disconnect, and Borges uses exceptions for
control flow.)
Vladimir Slepnev
More information about the Borges-users
mailing list