From: MenTaLguY Date: 2007-05-12T08:17:52+09:00 Subject: Re: basic threading question: can ruby use real threads? On Sat, 12 May 2007 07:47:57 +0900, "Bill Kelly" wrote: > If we could prevent Thread#raise from happening within an ensure block, > and we could guarantee that an assignment to a variable would similarly > be non-interruptable (meaning, an exception can't be raised between > the point where a method call completes, and its result is assigned to > a variable) ... wouldn't that be getting us pretty close to being able to > write "sane" code? Closer, but in this context "safe" is an all-or-nothing proposition. Simply making variable assignments atomic falls far, far short of what's needed. What you're actually groping towards is atomic transactions -- the ability to take an arbitrary block of code and say "if this block does not complete successfully, any of its effects should be rolled back before propagating the exception". Of course, not all effects (e.g. IO) _can_ be rolled back, so you're still not entirely safe in that case. > Or am I just missing out on something fundamental? (If so, I'm most > definitely interested to learn.) Yes. You have to be worried about all of the code involved (e.g. also the arbitrarily complex implementations of any methods you call), not just your own immediate code. -mental