[Top][All Lists]

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

Re: if-let/if-let*/and-let/..

From: Stefan Monnier
Subject: Re: if-let/if-let*/and-let/..
Date: Thu, 22 Feb 2018 00:10:22 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

> 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.

OK, that makes sense.

> 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).

The (SYMBOL) syntax is not very attractive, tho (to me, it really gives
me the impression that I'm binding SYMBOL to nil).  As a programmer, I'd
much rather write SYMBOL for that and if that's not an option, then
I'd use (_ SYMBOL) to make it clear that SYMBOL is just evaluated and
not bound.

> (pcase spec
>     (`(,(pred symbolp) . ,rest)
>      (pcase rest
>        (`(,_) (cl-callf list spec)) ;the single binding syntax
>        (_     (signal 'error (list "if-let: Bad binding spec" spec))))))

So you'd then support the SYMBOL syntax as a shorthand for (_ SYMBOL)
*except* as the first element of the spec?
That would be OK for me (tho the above error message might like to
suggest the use of (_ SYMBOL) to circumvent this restriction).


reply via email to

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