[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: if-let/if-let*/and-let/..
From: |
Michael Heerdegen |
Subject: |
Re: if-let/if-let*/and-let/.. |
Date: |
Thu, 22 Feb 2018 02:08:16 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.0.91 (gnu/linux) |
Stefan Monnier <address@hidden> writes:
> > (if-let* (x (y 1) (z 2)) "dogs" "cats") => "cats"
>
> Same as the first case above, we could/should detect this case during
> macro-expansion since this is not of the form (VAR EXP) but (VAR EXP
> EXP).
I understand now what the problem is.
Mark had implemented and-let* as in srfi-2:
https://srfi.schemers.org/srfi-2/srfi-2.html
(scroll to "Specification")
which interprets a (bound) symbol in the binding spec as a boolean.
Noam then had asked for making if-let's binding SPEC compatible with
that of the new and-let* - but the single-binding case of those was
incompatible with that, so foo-let* were born breaking with the single
binding case, and at that time we wanted to introduce these names
anyway. foo-let were then reimplemented based on foo-let* but made
still supporting the single-binding case for backward compatibility as
special case, and also marked obsolete to not have two versions of the
very same thing.
That treatment of a single SYMBOL in the SPEC is redundant AFAIK (in the
SRFI2 and in master) since it can also be written as (SYMBOL). If we
sacrifice the absolute rigid compatibility with SRFI2, we can treat the
binding SPEC, as Stefan suggested, like
#+begin_src emacs-lisp
(pcase spec
(`(,(pred symbolp) . ,rest)
(pcase rest
(`(,_) (cl-callf list spec)) ;the single binding syntax
(_ (signal 'error (list "if-let: Bad binding spec" spec))))))
#+end_src
being slightly backward incompatible since
| 4612b2a2b37026bef5a9b8e92878a15dabb9b261
| Parent: c87331a1c0 Merge branch 'master' of
git.savannah.gnu.org:/srv/git/emacs
| Merged: emacs-25
| Containing: emacs-26 master
| Follows: emacs-25.1 (130022)
|
| Implement and-let*
Michael.
- Re: if-let/if-let*/and-let/.., (continued)
- Re: if-let/if-let*/and-let/.., Mark Oteiza, 2018/02/13
- Re: if-let/if-let*/and-let/.., Stefan Monnier, 2018/02/13
- Re: if-let/if-let*/and-let/.., Mark Oteiza, 2018/02/13
- Re: if-let/if-let*/and-let/.., Michael Heerdegen, 2018/02/14
- Re: if-let/if-let*/and-let/.., Stefan Monnier, 2018/02/14
- Re: if-let/if-let*/and-let/.., Michael Heerdegen, 2018/02/20
- Re: if-let/if-let*/and-let/..,
Michael Heerdegen <=
- Re: if-let/if-let*/and-let/.., Stefan Monnier, 2018/02/22
- Re: if-let/if-let*/and-let/.., Michael Heerdegen, 2018/02/22
- Re: if-let/if-let*/and-let/.., Michael Heerdegen, 2018/02/13
- Re: if-let/if-let*/and-let/.., Eric Abrahamsen, 2018/02/13
- Re: if-let/if-let*/and-let/.., Michael Heerdegen, 2018/02/13
- Re: if-let/if-let*/and-let/.., Eric Abrahamsen, 2018/02/13