From: Juho S. <js...@ik...> - 2008-03-12 22:41:41
|
"Martin C. Martin" <mm...@it...> writes: > Juho Snellman wrote: > > "Martin C. Martin" <mm...@it...> writes: > >> Should @body be wrapped in an unwind-protect? > > Can't see why, given an interface like this where the cycle count is > > reported as a return value. If there was a non-local exit, we > > obviously can't return the value, because we need to finish the nlx. > > Why do we need to finish the nlx? I think the main use of this code > is while performance tuning, and if the non-local exit is occasionally > the way its supposed to exit, we'd want to add the times for those too. Right, it's expected. So we have to finish it, or the program will be doing something different than before the WITH-CYCLE-COUNTER was added. (defun foo () (loop (incf *total* (nth-value 2 (with-cycle-counter (if something (return-from foo) (do-something-else))))))) So "given an interface like this where the cycle count is reported as a return value" there are two options. Either we prevent the nlx in the uwp of WITH-CYCLE-COUNTER, in which case this program will loop infinitely. Or we finish it by returning from FOO, in which case we obviously will not be returning a value from WITH-CYCLE-COUNTER, and that iteration of the loop will be unaccounted, and the uwp was useless. -- Juho Snellman |