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

Vladimir Sedach vsedach at gmail.com
Tue Sep 4 02:22:24 UTC 2012


This I would definitely call a bug. Since the position PS takes right
now is that it doesn't have symbols as run-time objects, I made the
decision to disallow them as keys in CASE clauses. Only keyword
symbols (which are translated to strings), numbers and string literals
are allowed.

The behavior exhibited in your case is perfectly ok JavaScript though,
so the SWITCH special form still supports having variables and others
things as keys.

I made a note in the reference manual (in the repo, I'll update the
version on the PS website with the next release), and also fixed some
other bugs I found in CASE and SWITCh statements.

Thank you for bringing this issue up!

Vladimir

On Mon, Sep 3, 2012 at 8:09 AM, Boris Smilga <boris.smilga at gmail.com> wrote:
> 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.
>
> _______________________________________________
> parenscript-devel mailing list
> parenscript-devel at common-lisp.net
> http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel




More information about the parenscript-devel mailing list