Is there an idiomatic/commonly used/established convention to convert non-nil
values to t
that other Elisp programmers are likely to recognize?
Sometimes I have a non-nil
value, say from calling member
, that I want to return as either t
or nil
(so that I don't leak implementation details (Cf. Hyrum's Law)).
The Emacs Lisp Coding Conventions, for example, say nothing about this that I can see. The closest I've found is the Elisp manual's section on nil
and t
, which says "When you need to choose a value that represents true, and there is no other basis for choosing, use t
."
Ways I've come up with:
(and val t)
(if val t nil)
(not (not val))
Does one of these have a benefit over the other? Is one "more idiomatic"?
t
- which is the question @Stefan answered? You might consider simplifying the question to one or the other - or post two simplified questions.