I wrote this piece of code in general lisp (ignore ... since it is pointless to insert this part here).
(case turn (*red-player* ...) (*black-player* ...) (otherwise ...))
red-player and black-player are variables that were defined using the defvar statement to "mimic" the #define statement in C.
(defvar *red-player* 'r) (defvar *black-player* 'b)
As you can imagine, when the variable turn receives either the value *red-player* ('r) or *black-player* value (' b), the case statement does not work properly, as it expects this rotation to contain *red-player* as a literal, not the contents of the variable *red-player* .
I know that I can easily fix this with the cond or if + equal statements, as the contents of the variable are evaluated there, but I'm curious. Perhaps there is a way to create something like C macros in Lisp, or there is some special case statement that allows variables to be used instead of literals.
Thank you in advance!
source share