Define symbols


I want to define a set of constants whose values are symbols with the same name as the constant.

For example, (make-symbols x y z) should define x, y and z which evaluate to the symbols x, y and z respectively.


(define-syntax make-symbols
  (syntax-rules ()
    ((_ symbol ...)
       (define symbol 'symbol) ...))))

Credit: Vasilij Schneidermann


(make-symbols x y z)

(list x y z)
;; ==> (x y z)

(every symbol? (list x y z))
;; ==> #t

(map symbol->string (list x y z))
;; ==> ("x" "y" "z")

Back to the Scheme Cookbook