emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cond* Examples


From: Trevor Arjeski
Subject: Re: cond* Examples
Date: Sat, 11 Jan 2025 08:50:17 +0300
User-agent: Gnus/5.13 (Gnus v5.13)

Richard Stallman <rms@gnu.org> writes:
> Please try this replacement function:
>
>
> (defun cond*-non-exit-clause-p (clause)
>   "If CLAUSE, a cond* clause, is a non-exit clause, return t."
>   (or (null (cdr-safe clause))   ;; clause has only one element.
>       (and (cdr-safe clause)
>            ;; Starts with t.
>            (or (eq (car clause) t)
>                ;; Starts with a `bind*' pseudo-form.
>                (and (consp (car clause))
>                     (eq (caar clause) 'bind*))))))

This works! Thanks.

I do have one more thing that I noticed about bind*. If we take the
same snippet, but remove the `:non-exit' from the clause containing
`bind*', it appears that:

1. The `cond*' does not exit in the first clause, but should because the
first bind is t (see manual).

2. The scope of the binds are not contained to the clause and wrap the
entire `cond*'.

(cond*
 ((bind* (foo 1)
         (bar 2))) ; should exit here?
 ((eq foo bar) :eq)
 ((< foo bar) :lt)
 (t :nothing))
;; returns :lt

Trevor



reply via email to

[Prev in Thread] Current Thread [Next in Thread]