[parenscript-devel] CASE keys in Parenscript vs. Lisp

Boris Smilga boris.smilga at gmail.com
Mon Sep 3 12:09:20 UTC 2012


Hello.

I've noticed that Parenscript has a different semantics from Lisp as
regards keys of CASE clauses.  Lisp assumes an implicit QUOTE in this
context, so that a symbol used as CASE clause key matches a test-key
which is EQL to the symbol, as opposed to its value.  Parenscript, on
the other hand, translates CASE forms to switch statements where
symbol keys are used as identifiers.  E. g.

  (let* ((foo 'bar) (bar 'foo) (x bar))
    (case x ((foo) 1) ((bar) 2)))

translates to

  (function () {
      var foo = 'bar';
      var bar = 'foo';
      var x = bar;
      switch (x) {
      case foo:
          return 1;
      case bar:
          return 2;
      };
  })();

Note that the former evaluates to 1, the latter to 2.

Now, is this a bug, or a feature?  The section on CASE in the
Parenscript Manual is actually misleading, whatever the answer.

 — B. Smilga.




More information about the parenscript-devel mailing list