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

Gustavo gugamilare at gmail.com
Mon Apr 5 12:54:20 UTC 2010


Hello,

I thought that the whole purpose of *switch* was to compare some value to
the result of evaluated forms. I don't think it is nice to impose a
restriction that avoid using evaluated variables and forms, and I didn't
quite understand why it should.

As for allow either an atom or a list of forms, I don't like it very much,
but it should be more or less ok. Some particular cases should be analyzed
first, though, like

(switch (something)
  ('some-symbol ...)
  (*some-variable* ...)
  ...)

It could lead to a wrong interpretation unless you explicitly test if the
first symbol of your list is *quote*. Another solution is to require the
user to write more parenthesis

(switch (something)
  (('some-symbol) ...)
  (*some-variable* ...)
  ...)

An alternative to avoid this and other problems (e.g. excessive parenthesis)
is to allow the use of some key, like:

(switch (something)
  ((:any value1 value2 ...) ...)
  ((car some-list) ...)
  ...)

In my opinion, this would be much better. Using the key *:member* instead of
*:any* would be a good option too.

Cheers,

Gustavo.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/alexandria-devel/attachments/20100405/03e44b04/attachment.html>


More information about the alexandria-devel mailing list