>>>>> "Alexandre" == Alexandre <Alexandre.Fayolle@logilab.fr> writes:
Alexandre> On Thu, Feb 19, 2004 at 10:42:56AM +0800, Isaac To wrote:
>> It is *full* of goto. Those who are used to writing application code
>> will find it is all too tempted to simply "return" at the point of
>> error, and learn bitterly that the lock they are holding is not
>> unlocked, leaving them a dead kernel. It is possible to write
>> something like this
Alexandre> I had sworn I wouldn't join this thread... <sigh>
Alexandre> This cas is handled very cleanly by python's try...finally
Alexandre> construct, which take care of calling the cleanup code in
Alexandre> *all* cases, even the one you'd have forgotten.
I'm aware of them, although Python or Java's "try-finally" is not as clean
as C++'s "allocation is initialization", or C#'s "using" construct. On the
other hand, they are not available to C, so goto is the escape. Of course
one must do it in a disciplined way: putting goto in every place of your
code will kill you very quickly when reading your own code again. But goto
is really not as horrible as it sounds, especially for those people who
avoid them just because their structured programming teacher teach them that
way.
Regards,
Isaac.