I have uploaded a new version of my Alternatives library. In addition to the ALTERNATIVES
macro, there is an ALTERNATIVES*
macro which allows one to specify a name for the set of choices. Then, one can check the DOCUMENTATION
to see which alternative was last macroexpanded.
(defun random-letter ()
(alt:alternatives* random-letter-algorithm
***
(:constant-a
"Always pick the letter A."
#\A)
(:uniform
"Choose any letter with equal probability"
(random:random-elt "ABCDEFGHIJKLMNOPQRSTUVWXYZ"))))
(documentation 'random-letter-algorithm 'alt:alternatives)
=> "CONSTANT-A
Always pick the letter A."
(alt:alternatives* random-letter-algorithm
***
(:constant-a
"Always pick the letter A."
#\A)
(:uniform
"Choose any letter with equal probability"
(random:random-elt "ABCDEFGHIJKLMNOPQRSTUVWXYZ"))))
(documentation 'random-letter-algorithm 'alt:alternatives)
=> "CONSTANT-A
Always pick the letter A."