[alexandria-devel] Review cycle 2: SWITCH, ESCWITCH, and CSWITCH

Nikodemus Siivola nikodemus at random-state.net
Mon Apr 5 12:02:57 UTC 2010


Random rumination on SWITCH: I think part of the evaluate-or-not
confusion comes from C.

There it's common to have #define'd names as keys, which means that
non-evaluation of the keys is not an issue.

One option would be to specify that keys must either be non-symbol
atoms, or CONSTANTP symbols (evaluated), so

 (switch (value)
  (numeric-constant-1 ...)
  (numeric-constant-2 ...))

 (switch (value :test string-equal)
  (:keyword-1 ...)
  (:keyword-2 ...))

and

 (define-symbol-macro foobar "foobar")

 (switch (value :test equal)
  ("bar" ...)
  ("foo" ...)
  (foobar ...))

would all work nicely, but

 (switch (value)
  (local-var ...))

would not be legal.

The formulation or "non-symbol atom or CONSTANTP symbol" seems pretty
arbitrary, though.

Cheers,

 -- Nikodemus




More information about the alexandria-devel mailing list