chickadee » miscmacros » define-enum

(define-enum ->INT ->SYM ID ...)syntax

Defines an enumeration. The variables ID, ... are bound to the exact integers 0, 1, ... with define-constant. ID may also take the form (ID N), in which case the counter will be set to the exact integer N for that variable, and continue upward normally from there. A procedure named ->INT will be defined that takes a symbols and returns the respective integer. A procedure ->SYM will also be defined that takes an integer and returns the respective symbol (from the set of IDs). If a symbol doesn't map to an integer (or vice versa), #f is returned.