[parenscript-devel] Keyword arguments and quoted symbols in Parenscript
Red Daly
reddaly at gmail.com
Sat Apr 25 16:38:50 UTC 2009
Hello ParenScripters,
I have modified the behavior of keywords found in Parenscript source to be
parsed into (PS-QUOTE keyword) instead of (JS-VARIABLE keyword). 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...')
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/parenscript-devel/attachments/20090425/aa6d52cd/attachment.html>
More information about the parenscript-devel
mailing list