Hi Russell, That makes sense. I pushed a patch that's similar to yours (I just wanted to move the assert into the cond in that function).
Thank you for your contribution! Vladimir On Sat, Jun 2, 2012 at 3:27 AM, Russell Sim <[email protected]> wrote: > > Hey, > > I have hit another small bug while I was using some older code which was > using quoted symbols as keys when defining an object. For example when > I evaluate > > CL-USER> (ps:ps (ps:create 'test "bang" 'symbol-saved-my-life "parenscript")) > > I get the following error. > > Slot key 'TEST is not one of symbol, string or number. > [Condition of type SIMPLE-ERROR] > > > I have personally been using keywords instead of quoted symbols but it > seems there was a time when quoted symbols were ok and the documentation > seems to suggest that symbols should be fine? > > The following patch enables quoted symbols to work again and will > convert them to the appropriate camelCase form. > > CL-USER> (ps:ps (ps:create 'test "bang" 'symbol-saved-my-life "parenscript")) > "({ 'test' : 'bang', 'symbolSavedMyLife' : 'parenscript' });" > > > Cheers, > Russell > > > commit 84d94815b1655179b283627a64bf6ed1ac1dba07 (HEAD, refs/heads/master) > Author: Russell Sim <[email protected]> > Date: Sat Jun 2 14:48:20 2012 +1000 > > Allow quoted strings to be used as keys in objects > > Modified src/non-cl.lisp > diff --git a/src/non-cl.lisp b/src/non-cl.lisp > index f2ed0e7..5cba0a8 100644 > --- a/src/non-cl.lisp > +++ b/src/non-cl.lisp > @@ -52,12 +52,18 @@ > `(ps-js:object > ,@(loop for (key val-expr) on arrows by #'cddr collecting > (progn > - (assert (or (stringp key) (numberp key) (symbolp key)) > - () > - "Slot key ~s is not one of symbol, string or number." > - key) > - (cons (aif (and (symbolp key) (reserved-symbol? key)) it key) > - (compile-expression val-expr)))))) > + (assert (or (stringp key) (numberp key) (symbolp key) (eq > 'quote (car key))) > + () > + "Slot key ~s is not one of symbol, string or number." > + key) > + (cons (acond > + ((and (symbolp key) (reserved-symbol? key)) > + it) > + ((and (consp key) (eq 'quote (car key))) > + (symbol-to-js-string (eval key))) > + (t > + key)) > + (compile-expression val-expr)))))) > > (define-expression-operator %js-getprop (obj slot) > (let ((expanded-slot (ps-macroexpand slot)) > > > > _______________________________________________ > parenscript-devel mailing list > [email protected] > http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel _______________________________________________ parenscript-devel mailing list [email protected] http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
