Very interesting. So basically, you'll still need a runtime library to execute PS code in a CL environment, but you won't need an interpreter. (This is an observation Scott made to me earlier today.) Is that correct? <div>
<br></div><div>It's a neat insight to have observed how close PS was to being able to make this work. That is, it's a big task, but not nearly as big as one would have thought.</div><div><br></div><div>I'm curious as to what you propose to do with this capability. What practical applications?</div>
<div><br></div><div>One I can think of that would get me excited is the ability to evaluate PS forms in Slime (or something like it... Pslime anybody?). Perhaps this could even be hooked into sldb for the purpose of debugging PS code in a much more friendly environment than the likes of Firebug, not least because it would be linked to PS source rather than generated JS.</div>
<div><br></div><div>Daniel</div><div><br><br><div class="gmail_quote">On Tue, Apr 20, 2010 at 1:04 PM, Vladimir Sedach <span dir="ltr"><<a href="mailto:vsedach@gmail.com">vsedach@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">> What is the motivation for using lists as the intermediate form rather than<br>
> CLOS objects? I suppose that s-expressions makes it easy to use<br>
> tree-walking functions out of the box, but there seem to be disadvantages<br>
> when it comes to separating syntax from semantics, e.g. addressing the<br>
> 'else' form of an if via (third if-statement) vs. (if-statement-else<br>
> if-statement).<br>
> I have not seen the intermediary form and I am sure you have good reasons,<br>
> but it is not the direction I would have gone. Could you explain the choice<br>
> perhaps with some motivating examples, to enlighten us all?<br>
<br>
</div>Here's an example of what the current intermediate form looks like:<br>
<br>
(compile-statement '(defun blep (ss x y)<br>
(when foo?<br>
(let ((pair (bar)))<br>
(unless (null pair)<br>
(destructuring-bind (a b) pair<br>
(unless (or (null a) (null b))<br>
(let ((val (baz a b)))<br>
(unless (null val)<br>
(when (blah val)<br>
(unless (blee)<br>
t)))))))))))<br>
<br>
=><br>
<br>
(JS:DEFUN BLEP (SS X Y)<br>
(JS:BLOCK<br>
(JS:IF FOO?<br>
(JS:BLOCK (JS:VAR PAIR (JS:FUNCALL BAR))<br>
(JS:IF (JS:!== PAIR NIL)<br>
(JS:BLOCK (JS:VAR A (JS:AREF PAIR 0)) (JS:VAR B (JS:AREF PAIR 1))<br>
(JS:IF (JS:! (JS:|\|\|| (JS:=== A NIL) (JS:=== B NIL)))<br>
(JS:BLOCK (JS:VAR VAL (JS:FUNCALL BAZ A B))<br>
(JS:IF (JS:!== VAL NIL)<br>
(JS:BLOCK<br>
(JS:IF (JS:FUNCALL BLAH VAL)<br>
(JS:BLOCK<br>
(JS:IF (JS:! (JS:FUNCALL BLEE))<br>
(JS:BLOCK (JS:RETURN T)))))))))))))))<br>
<br>
<br>
As you can see, all you need is to define some functions and macros,<br>
and the resulting code is ready to be EVALed or compiled.<br>
<div class="im"><br>
<br>
> Go, Vladimir, go! That's an ambitious project but I would love to see it<br>
> happen!<br>
> Please not that there is a project with a viable javascript parser and<br>
> printer already. See <a href="http://github.com/gonzojive/js-parser" target="_blank">http://github.com/gonzojive/js-parser</a><br>
> I adapted the code from JWACS (Javascript With Advanced Continuations<br>
> Support) into a new project for parsing javascript. The original JWACS<br>
> included a pretty printer and an obfuscating printer that would obfuscate<br>
> non-toplevel variables. It also had a Javascript-like grammar with a few<br>
> extra syntax additions.<br>
> The syntax tree represents javascript with structures rather than lists for<br>
> everything, but you should be able to avoid writing the parser yourself, at<br>
> the very least.<br>
<br>
</div>Thanks for the pointer. I didn't know you based your parser on JWACS'.<br>
I took a look at JWACS when starting, but decided to base mine on<br>
Marijn Haverbeke's parse-js (<a href="http://marijn.haverbeke.nl/parse-js/" target="_blank">http://marijn.haverbeke.nl/parse-js/</a>);<br>
it seemed easier to modify.<br>
<font color="#888888"><br>
Vladimir<br>
</font><div><div></div><div class="h5"><br>
>> One user-visible change I made in the latest patches is to encourage<br>
>> use of CL equality predicates ('==' and '===' are still there but<br>
>> marked as deprecated).<br>
>><br>
>> Vladimir<br>
>><br>
><br>
> Red<br>
><br>
>><br>
>> 2010/4/19 John Pallister <<a href="mailto:john@synchromesh.com">john@synchromesh.com</a>>:<br>
>> > +1, as they say...<br>
>> ><br>
>> > ++Thanks,<br>
>> ><br>
>> > John :^P<br>
>> ><br>
>> > On Mon, Apr 19, 2010 at 12:42 AM, Daniel Gackle <<a href="mailto:danielgackle@gmail.com">danielgackle@gmail.com</a>><br>
>> > wrote:<br>
>> >> For those of us who are curious, could you talk a bit about the work<br>
>> >> you did<br>
>> >> on the compiler?<br>
>> >> Thanks Vladimir,<br>
>> >> Daniel<br>
>> ><br>
>> > _______________________________________________<br>
>> > parenscript-devel mailing list<br>
>> > <a href="mailto:parenscript-devel@common-lisp.net">parenscript-devel@common-lisp.net</a><br>
>> > <a href="http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel" target="_blank">http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel</a><br>
>> ><br>
>><br>
>> _______________________________________________<br>
>> parenscript-devel mailing list<br>
>> <a href="mailto:parenscript-devel@common-lisp.net">parenscript-devel@common-lisp.net</a><br>
>> <a href="http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel" target="_blank">http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel</a><br>
><br>
><br>
> _______________________________________________<br>
> parenscript-devel mailing list<br>
> <a href="mailto:parenscript-devel@common-lisp.net">parenscript-devel@common-lisp.net</a><br>
> <a href="http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel" target="_blank">http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel</a><br>
><br>
><br>
<br>
_______________________________________________<br>
parenscript-devel mailing list<br>
<a href="mailto:parenscript-devel@common-lisp.net">parenscript-devel@common-lisp.net</a><br>
<a href="http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel" target="_blank">http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel</a><br>
</div></div></blockquote></div><br></div>