Hello list,
While people are discussing future directions for ParenScript, I thought I'd add my two cents.
I am developing systems based around XHTML, X3D and Adobe Flex; in all three cases we have an XML-syntax language with an embedded JavaScript language. Except that X3D uses ECMAScript 2 (which AFAIK is "standard" XHTML JavaScript 1.x) while Flex (i.e. Flash 9) uses ActionScript 3.0, which is an implementation of ECMAScript 262 Revision 4 [1], a.k.a. JavaScript 2.0 [2].
The point is, ECMAScript 4 has a variety of new features (optional static typing, classes, interfaces, packages, generators, list comprehensions etc. - there's a nice overview at [3]) which aren't currently supported by ParenScript. Given that the adoption of ECMAScript 4/JavaScript 2 is a case of when rather than if [4], it would be great if any overhaul of ParenScript could be done with an eye to incorporating some or all of these features in the near future (hopefully by other interested parties such as myself).
The "add a compiler" POV vs. the "keep it simple" perspective echoes the two sides of the JavaScript 2 debate. Since these new language features will be added (and I'm already using them in ActionScript 3), it would be great if they could be added to ParenScript without causing too much inconvenience to those who like it the way it is now.
I would like to help out with this task; I might have some time to spend on it later in the year.
Cheers,
John :^P
[1] http://www.ecmascript-lang.org/ - includes reference impl. in Standard ML [2] "ActionScript 3: The Language of Flex. A Conversation with James Ward, Part I", http://www.artima.com/lejava/articles/actionscript.html [3] http://developer.mozilla.org/presentations/xtech2006/javascript/ [4] http://www.mozilla.org/projects/tamarin/
The process of adding new compiler macros to the current Parenscript to support Javascript 2.0 is very easy. See the example later in the email. However, the tricky design issue is how to disallow Javascript 2.0generation when you only want ECMAScript 2 syntax. As the compiler becomes more sophisticated, this option flag may have more ramifications (because of semantic analysis). I do not foresee any grave problems, however, and am in favor of adding support for Javascript 2 so long as it can be disabled.
On 6/24/07, John Pallister john@synchromesh.com wrote:
...
The point is, ECMAScript 4 has a variety of new features (optional static
typing, classes, interfaces, packages, generators, list comprehensions etc. - there's a nice overview at [3]) which aren't currently supported by ParenScript. Given that the adoption of ECMAScript 4/JavaScript 2 is a case of when rather than if [4], it would be great if any overhaul of ParenScript could be done with an eye to incorporating some or all of these features in the near future (hopefully by other interested parties such as myself).
While a adoption of new technology is inevitable, it is not instantaneous. For most people, it will be a few years before they can fully embrace the new version of Javascript.
The "add a compiler" POV vs. the "keep it simple" perspective echoes the two
sides of the JavaScript 2 debate. Since these new language features will be added (and I'm already using them in ActionScript 3), it would be great if they could be added to ParenScript without causing too much inconvenience to those who like it the way it is now.
I would like to help out with this task; I might have some time to spend on it later in the year.
I will provide some instruction for those who want to modify the behavior of the Parenscript compiler in a basic way. Here is an example of how to add a macro `(js-literal string)' for including Javascript literals directly in Parenscript. It should elucidate the process of basic modification of the Parenscript compiler:
;;; Define the AST node (defjsclass js-literal-statement (statement) ((text :accessor js-literal-text :initarg :text)) (:documentation "An opaque Javascript literal"))
;;; Define the macro to include such a kludge in your code (define-js-compiler-macro js-literal (js-string) (make-instance 'js-literal-statement :text js-string))
;;; Define the translation function for compiling to javascript (defmethod js-to-strings ((statement js-literal-statement) start-pos) (declare (ignore start-pos) (inline lisp-special-char-to-js)) (list (js-literal-text statement)))
If I'm not mistaken, you can now include Javascript with the Parenscript form (js-literal "..."). so (js-literal "class Greeter { var saying = 'hello, world'; }") emits "class Greater ..." in the Javascript source output.
Cheers,
John :^P
Red
[3] http://developer.mozilla.org/presentations/xtech2006/javascript/
On 6/25/07, Red Daly reddaly@gmail.com wrote:
If I'm not mistaken, you can now include Javascript with the Parenscript form (js-literal "..."). so (js-literal "class Greeter { var saying = 'hello, world'; }") emits "class Greater ..." in the Javascript source output.
Since a recent patch by Attila you can simply use quote followed by a string to embed literal javascript.
(js:js* '(progn (alert "paren") '"alert('js');"))
"alert('paren'); alert('js');"
/Henrik
That is definitely something I'm thinking of, and as Red pointed out it may not be particularly hard but it will be tricky. Before we decided to stick by ParenScript and DHTML at my startup (we considered switching to Peter Seibel's Javascript generator and writing our own), we were contemplating writing the UI in Flash/Flex, possibly in parallel with the DHTML version. I still think that there is a possibility we might do this in the future, and if we will, it will be by extending ParenScript to target Flash as another platform.
I welcome any contributions to extend ParenScript to generate ECMAScript 4. Let me know if you need any help.
Thanks, Vladimir
On 6/24/07, John Pallister john@synchromesh.com wrote:
Hello list,
While people are discussing future directions for ParenScript, I thought I'd add my two cents.
I am developing systems based around XHTML, X3D and Adobe Flex; in all three cases we have an XML-syntax language with an embedded JavaScript language. Except that X3D uses ECMAScript 2 (which AFAIK is "standard" XHTML JavaScript 1.x) while Flex (i.e. Flash 9) uses ActionScript 3.0, which is an implementation of ECMAScript 262 Revision 4 [1], a.k.a. JavaScript 2.0 [2].
The point is, ECMAScript 4 has a variety of new features (optional static typing, classes, interfaces, packages, generators, list comprehensions etc. - there's a nice overview at [3]) which aren't currently supported by ParenScript. Given that the adoption of ECMAScript 4/JavaScript 2 is a case of when rather than if [4], it would be great if any overhaul of ParenScript could be done with an eye to incorporating some or all of these features in the near future (hopefully by other interested parties such as myself).
The "add a compiler" POV vs. the "keep it simple" perspective echoes the two sides of the JavaScript 2 debate. Since these new language features will be added (and I'm already using them in ActionScript 3), it would be great if they could be added to ParenScript without causing too much inconvenience to those who like it the way it is now.
I would like to help out with this task; I might have some time to spend on it later in the year.
Cheers,
John :^P
[1] http://www.ecmascript-lang.org/ - includes reference impl. in Standard ML [2] "ActionScript 3: The Language of Flex. A Conversation with James Ward, Part I", http://www.artima.com/lejava/articles/actionscript.html [3] http://developer.mozilla.org/presentations/xtech2006/javascript/ [4] http://www.mozilla.org/projects/tamarin/ -- John Pallister john@synchromesh.com Wellington, New Zealand
parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
parenscript-devel@common-lisp.net