all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ted Zlatanov <tzz@lifelogs.com>
To: help-gnu-emacs@gnu.org
Subject: Re: condition-case
Date: Wed, 15 Dec 2010 10:50:38 -0600	[thread overview]
Message-ID: <877hfbx9nl.fsf@lifelogs.com> (raw)
In-Reply-To: jwvbp4n3aad.fsf-monnier+gnu.emacs.help@gnu.org

On Tue, 14 Dec 2010 23:55:45 -0500 Stefan Monnier <monnier@iro.umontreal.ca> 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


  reply	other threads:[~2010-12-15 16:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <33e7a222-992c-4fc2-bbd2-d987a0d4d9b1@j32g2000prh.googlegroups.com>
2010-11-28 23:44 ` Fwd: condition-case Fren Zeee
2010-11-29  1:25   ` Glenn Morris
     [not found] ` <877hfxokvh.fsf@lola.goethe.zz>
     [not found]   ` <4d4ecf83-ffd8-43d9-8c27-4123856273e9@21g2000prv.googlegroups.com>
     [not found]     ` <0b6e72ef-a605-4ac1-bc71-f3e180f162fb@j18g2000prn.googlegroups.com>
     [not found]       ` <87r5e3zxyw.fsf@kuiper.lan.informatimago.com>
     [not found]         ` <878w06lqcf.fsf@lifelogs.com>
     [not found]           ` <8762vaodaw.fsf@kuiper.lan.informatimago.com>
     [not found]             ` <8762v6ho6q.fsf@lifelogs.com>
     [not found]               ` <jwv62v6ljkb.fsf-monnier+gnu.emacs.help@gnu.org>
     [not found]                 ` <87hbepd50p.fsf@lifelogs.com>
     [not found]                   ` <jwvmxohh8yt.fsf-monnier+gnu.emacs.help@gnu.org>
     [not found]                     ` <87pqtc9sd5.fsf@lifelogs.com>
     [not found]                       ` <jwvbp4v9enz.fsf-monnier+gnu.emacs.help@gnu.org>
2010-12-10 18:40                         ` condition-case Ted Zlatanov
2010-12-10 21:43                           ` condition-case Stefan Monnier
2010-12-13 17:12                             ` condition-case Ted Zlatanov
2010-12-13 17:10                           ` condition-case Ted Zlatanov
2010-12-15  4:55                             ` condition-case Stefan Monnier
2010-12-15 16:50                               ` Ted Zlatanov [this message]
2010-12-16 22:03                                 ` condition-case Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877hfbx9nl.fsf@lifelogs.com \
    --to=tzz@lifelogs.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.