<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Oct 30, 2009, at 7:32 AM, Gary Byers wrote:</div><blockquote type="cite"><div><font class="Apple-style-span" color="#000000"><br></font>On Fri, 30 Oct 2009, Alexander Repenning wrote:<br><br><font class="Apple-style-span" color="#006312"><br></font>If instead of providing that information you're simply noting that<br>"crashing is bad", for once I'm in full agreement with you.<br><br></div></blockquote><div><br></div><div>Hurray! </div><br><blockquote type="cite"><div><font class="Apple-style-span" color="#006312"><br></font>Since I don't know how to ensure that that cleanup will occur in<br>the event of a non-local exit, one approach to being able to have<br>errors in #/drawRect: methods and live to tell about it is to establish<br>a restart in the #/drawRect: method and transfer control to it in case<br>of error:<br><br>(objc:defmethod (#/drawRect: :void) ((self some-view) (rect #>NSRect))<br>  (with-simple-restart (abandon-drawing "Stop trying to draw in ~s" self)<br>    (progn<br>      ...<br>      (if (zerop (random 10))<br>        (error "You're number's up.")<br>        (do-some-drawing ...)))))<br><br></div></blockquote><div><br></div><div>This works quite nicely, thanks! The overhead is < 1 us which is essentially nothing for something like draw which has a general overhead of almost 1ms even on a fast intel-mac. I tried handler-case which did work too but did not allow the developer to poke around in the call stack.</div><br><blockquote type="cite"><div>In practice, I think that in (most ? all ?) of the cases where I've<br>had errors in event handlers it was indeed possible to simply<br>abandon the event.<br><br></div></blockquote><div><br></div><div>You must be programming different things. We end up with most cases NOT working.</div><br><blockquote type="cite"><div>It's certainly reasonable to expect lisp-like behavior from lisp<br>code; it's less reasonable to expect that kind of behavior from<br>ObjC code, and recovering from errors on the event thread requires<br>either the cooperation of both kinds of code or at least some<br>basic awareness of the issues on the part of the developer.  I<br>don't think that it's possible to get ObjC code that wasn't<br>written with error recovery in mind to cooperate with the<br>error recovery process; I can't imagine what that'd mean.<br></div></blockquote><div><br></div><div>The restart approach you suggested works well, i.e., we do not have to rely on Objective-C to play nicer. It is pretty reasonable to wrap up handlers with this kind of restart functionality and only needs to be done at some strategic places to cover most of the cases.</div><div><br></div><div>Thanks Gary,  Alex</div><br></div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">Prof. Alexander Repenning</font></p><p style="margin: 0.0px 0.0px 0.0px 0.0px"><br class="khtml-block-placeholder"></p><p style="margin: 0.0px 0.0px 0.0px 0.0px">University of Colorado</p><p style="margin: 0.0px 0.0px 0.0px 0.0px">Computer Science Department</p><p style="margin: 0.0px 0.0px 0.0px 0.0px">Boulder, CO 80309-430</p><p style="margin: 0.0px 0.0px 0.0px 0.0px"><br class="khtml-block-placeholder"></p><p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">vCard: <a href="http://www.cs.colorado.edu/~ralex/AlexanderRepenning.vcf">http://www.cs.colorado.edu/~ralex/AlexanderRepenning.vcf</a></font></p><br class="Apple-interchange-newline"></span></span></span></span>
</div>
<br></body></html>