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

Daniel Gackle danielgackle at gmail.com
Fri Sep 14 02:15:32 UTC 2012


Trying to upgrade to the latest PS, I have a problem with this CASE fix:
it rejects symbol macros that expand to numbers. It's quite handy to
use symbol macros this way for compile-time constants, so I hope
the desired behavior can be restored.

Daniel


On Mon, Sep 3, 2012 at 7:22 PM, Vladimir Sedach <vsedach at gmail.com> wrote:

> 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
>
> _______________________________________________
> parenscript-devel mailing list
> parenscript-devel at common-lisp.net
> http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/parenscript-devel/attachments/20120913/0a15112d/attachment.html>


More information about the parenscript-devel mailing list