Introduce an enumeration type, like an
(defenum name elements &key mode ; current defun-mode by default parents ; nil by default short ; nil by default long ; nil by default )
(defenum day-p (:monday :tuesday :wednesday :thursday :friday :saturday :sunday))
results in a new function,
I often use keyword symbols as the elements, but any objects (even conses) can be used.
The recognizer just tests its argument against the elements, in order.
Because of this, you might want to order your elements so that the most common
elements come first. For instance,
The recognizer uses eq or eql checks where possible, so if your enumeration includes a mix of, say, conses and atom like symbols, you may wish to put the atoms first.
Checking the argument against each element is probably a perfectly good strategy when the number of elements is small (perhaps fewer than 20) and when the equality checks are relatively fast (e.g., symbols, characters, numbers). It is probably is not a good strategy otherwise. If you want to use defenum for something more complex, it might be best to modify it to adaptively use a fast alist or other schemes, based on the elements it is given.