bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#30749: 26.0.91; (cl-)case is confused when a nil atom is used instea


From: Alex Bennée
Subject: bug#30749: 26.0.91; (cl-)case is confused when a nil atom is used instead of a keylist
Date: Thu, 08 Mar 2018 11:34:59 +0000
User-agent: mu4e 1.1.0; emacs 26.0.91

Noam Postavsky <npostavs@gmail.com> writes:

> Alex Bennée <alex.bennee@linaro.org> writes:
>
>> I got confused why my case statement was failing as I'd used the second
>> form assuming that having nil as an atom would work. I'm not sure why
>> the quoting fixed it but it's certainly a confusing inconsistency.
>
> 'nil is the same as (quote nil)

Ahh so ends up as a list containing nil?

>
>> I think this is probably fixable with just making the docstring clearer
>> as the results of handling the duel atom/list of nil might have
>> unexpected results.
>
> So just add a "non-nil" perhaps?
>
> --- i/lisp/emacs-lisp/cl-macs.el
> +++ w/lisp/emacs-lisp/cl-macs.el
> @@ -763,7 +763,7 @@ cl-case
>    "Eval EXPR and choose among clauses on that value.
>  Each clause looks like (KEYLIST BODY...).  EXPR is evaluated and compared
>  against each key in each KEYLIST; the corresponding BODY is evaluated.
> -If no clause succeeds, cl-case returns nil.  A single atom may be used in
> +If no clause succeeds, cl-case returns nil.  A single non-nil atom may be 
> used in
>  place of a KEYLIST of one atom.  A KEYLIST of t or `otherwise' is
>  allowed only in the final clause, and matches if no other keys match.
>  Key values are compared by `eql'.

Works for me.

--
Alex Bennée





reply via email to

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