Re: Using cl-case on symbols
Tassilo Horn <[email protected]> Tue, 07 Jul 2026 07:00:33 +0200
| Newsgroups | gmane.emacs.help |
|---|---|
| Message-ID | <[email protected]> |
Heime <[email protected]> writes: > It has been suggested to me about using the following `cl-case' > construct for checking ACTM against a list of symbols. With `cond' I > would have to use ((or (eq actm 'add) (eq actm 'remove)) > > How is it that `cond' does not work on symbols but `cl-case' does? `cond' works with everything because you define the complete condition yourself. E.g., (cond ((> i 17) 'i-is-greater-than-17) (t 'i-is-something-else)) `cl-case' is more specialized. It only tests for equality or set membership using `eql'/`memql'. So the above greater-than test is not feasible to express with `cl-case' (well, unless you write a clause with a list containing all numbers > 17 of which there are many). > Although I have looked at the documentation of `cl-case', there is > no indication on its appropriateness to symbols. As said above, `cl-case' uses `eql' for comparison. Two interned symbols with the same name are `eq' so they are `eql', too. Keywords can also be compared with `eq' (and thus `eql'). And numbers can be compared with `eql'. So these are the types suitable for a `cl-case' expression. For example, strings are NOT suited. HTH, Tassilo