Hi Red,
I have modified the behavior of keywords found in Parenscript source to be parsed into (PS-QUOTE keyword) instead of (JS-VARIABLE keyword).
The current behavior is (ps::compile-parenscript-form :baz) => :baz (there's no quoting involved). The printer then outputs keyword symbols as strings, since this is the closest analogue (a self-evaluating object) to keywords among the native JavaScript objects.
This seems to make more sense because in Lisp, evaluating a keyword yields the keyword itself rather than the value bound to it. As a result, the ability to paass keyword arguments to functions is now restored.
CL-USER> (ps:ps (foo "bar" :quix "quo" :etc "etc...")) "foo('bar', { quix : 'quo', etc : 'etc...' });"
Whereas this used to yield foo('bar', quix, 'quo', etc, 'etc...')
This is actually a fix to keyword argument handling: previously the PS lambda-list handling code assumed that whenever it encountered a keyword in the arglist of a function, it was the beginning of the keyword portion of the lambda list, and started making the object at that point. This of course may not be the case if you are trying to use keywords as arguments to a function. With keywords compiled to strings, you get self-evaluating objects and can do keyword handling in the function body at runtime (which is what the current code does).
Thanks, Vladimir
In general, symbols occupy a strange place in Parenscript. Javascript has no analogue of Lisp symbols, so there is no sensible translation of symbols that works for everyone. Nonetheless, quoted symbols are used in many Parenscript macros to fake having real symbols in javascript. We could build in the ability to translate symbols to some javascript form, e.g.
(ps:ps (make-instance 'animal)) => makeInstance( symbolTable["ANIMAL"] )
The latter part of this post is just food for thought. I will go ahead and commit the patch for the former part of this post unless someone objects.
Red
parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel