From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.help Subject: Re: condition-case Date: Wed, 15 Dec 2010 10:50:38 -0600 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <877hfbx9nl.fsf@lifelogs.com> References: <33e7a222-992c-4fc2-bbd2-d987a0d4d9b1@j32g2000prh.googlegroups.com> <877hfxokvh.fsf@lola.goethe.zz> <4d4ecf83-ffd8-43d9-8c27-4123856273e9@21g2000prv.googlegroups.com> <0b6e72ef-a605-4ac1-bc71-f3e180f162fb@j18g2000prn.googlegroups.com> <87r5e3zxyw.fsf@kuiper.lan.informatimago.com> <878w06lqcf.fsf@lifelogs.com> <8762vaodaw.fsf@kuiper.lan.informatimago.com> <8762v6ho6q.fsf@lifelogs.com> <87hbepd50p.fsf@lifelogs.com> <87pqtc9sd5.fsf@lifelogs.com> <877hfh4gl5.fsf@lifelogs.com> <87zks9mwe1.fsf@lifelogs.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1292435130 21607 80.91.229.12 (15 Dec 2010 17:45:30 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 15 Dec 2010 17:45:30 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Dec 15 18:45:26 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PSvNS-00044V-BO for geh-help-gnu-emacs@m.gmane.org; Wed, 15 Dec 2010 18:45:21 +0100 Original-Received: from localhost ([127.0.0.1]:52139 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PSvNC-0006PM-Nh for geh-help-gnu-emacs@m.gmane.org; Wed, 15 Dec 2010 12:42:42 -0500 Original-Path: usenet.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!t-online.de!news.albasani.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 43 Original-X-Trace: news.albasani.net qj8amc6Kekqp2kZUahMhAXYFfbKoceKQVLwpTbTSuAc/QgzziSopft4oxbtWBW2l7vkKUgzj/udaPNVyflhAzw== Original-NNTP-Posting-Date: Wed, 15 Dec 2010 16:50:38 +0000 (UTC) X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6; d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" Cancel-Lock: sha1:rkDhxraSixN8TftYO5CAB0C/Ovk= sha1:Z+QJmaeyIM22PVoo0vUJIp6vSLc= User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux) Injection-Info: news.albasani.net; logging-data="+T6In4CO+F4HrCNJO1B80pqTE4cR/d5wWnpp4ryIdC68k4EBqCjV5BB12Ku3kEf31EHPSmqVJMVcmVeuYdHCJ0vtU2tGiTOlXLJch4WMyIZ5B49wJB4uu7FmQWN0Egqf"; mail-complaints-to="abuse@albasani.net" Original-Xref: usenet.stanford.edu gnu.emacs.help:183315 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:77564 Archived-At: On Tue, 14 Dec 2010 23:55:45 -0500 Stefan Monnier wrote: >> ...in other words, in the example you showed, is it just >> (let ((b a)) >> (lambda () '(b b c))) SM> Yes. I.e. let the interpreter perform the substitution, at run-time. OK, so would it work as: (defmacro handler-case (expression &rest clauses) "Evaluate expression with `condition-case' and catch errors with CLAUSES. Longer explanation here..." (let* ((var (gensym)) (neclause (assoc :NO-ERROR clauses)) (nell (cadr neclause)) (nebody (cddr neclause)) (handlers (mapcar (lambda (clause) (let ((typespec (car clause)) (clausvar (cadr clause)) (body (cddr clause))) (cons (if (and (consp typespec) (eq 'or (car typespec))) (cdr typespec) typespec) (if (null clausvar) body (let ((var (car clausvar))) body))))) (remove neclause clauses)))) (if neclause `(condition-case ,var (multiple-value-bind ,nell ,expression ,@nebody) ,@handlers) `(condition-case ,var ,expression ,@handlers)))) Does that new `let' that pops the clause need to evaluated? And should it maybe be a `lexical-let'? Ted