Re: Non Local Exits: Some usage notes
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Non Local Exits: Some usage notes
 
- From: Mark Hamburg <mhamburg@...>
 
- Date: 2005年8月12日 15:33:51 -0700
 
Nice notes on the usage of non-local exits. I should go back and re-read
more of the Dylan material sometime.
I will note that the big win in general is using finally to provide an
approach to writing wrappers that doesn't hurt one's head. Contrast:
 function do_with_lock( lock, fn, ... )
 lock:lock()
 return fn( ... )
 finally
 lock:unlock()
 end
(Blocks elided here.)
With what one has to write today:
 function pcall2call( success, ... )
 if success then
 return ...
 else
 error( ..., 0 )
 end
 end
 function unlocker( lock, ... )
 lock:unlock()
 return pcall2call( ... )
 end
 function do_with_lock( lock, fn, ... )
 lock:lock()
 return unlocker( lock, pcall( fn, ... ) ) )
 end
Mark