[parenscript-devel] automate javascript -> parenscript conversion

Lui Fungsin fungsin.lui at gmail.com
Fri Feb 15 01:18:16 UTC 2008


Hi,

I found that manually converting javascript (sample code) to
parenscript is quite annoying.

Does anyone know if writing a parser/converter (in lisp, perhaps) to
automate this task is a major undertaking or is relatively easy?
(maybe using some of the existing lisp libraries)

The reason to convert existing javascript to parenscript is that it's
easier to write/maintain afterwards (you have macro, emacs's paredit
mode, etc). Also, it's a lot easier to integrate in-line with cl-who
or other similar libraries whereas with existing javascript you need
to link them with the script tag (otherwise you have to escape all the
quotes, backslashes etc to include it as a really longggggg string).

>From my experience of converting existing javascript code to
parenscript, the oo method call conversion is most troublesome.

i.e.  x.getobj().slot1.slot2.method1()

/* hard to read backward if you're used to js */
=> (.method (aref (aref (.getobj x) "slot1") "slot2"))

/* easier to read but required a temp variable */
or (let ((obj (.getobj x))) (.method1 obj.slot1.slot2))

thanks



More information about the parenscript-devel mailing list