[parenscript-devel] Lexical scoping bug
vsedach at gmail.com
Tue Apr 20 19:04:44 UTC 2010
> What is the motivation for using lists as the intermediate form rather than
> CLOS objects? I suppose that s-expressions makes it easy to use
> tree-walking functions out of the box, but there seem to be disadvantages
> when it comes to separating syntax from semantics, e.g. addressing the
> 'else' form of an if via (third if-statement) vs. (if-statement-else
> I have not seen the intermediary form and I am sure you have good reasons,
> but it is not the direction I would have gone. Could you explain the choice
> perhaps with some motivating examples, to enlighten us all?
Here's an example of what the current intermediate form looks like:
(compile-statement '(defun blep (ss x y)
(let ((pair (bar)))
(unless (null pair)
(destructuring-bind (a b) pair
(unless (or (null a) (null b))
(let ((val (baz a b)))
(unless (null val)
(when (blah val)
(JS:DEFUN BLEP (SS X Y)
(JS:BLOCK (JS:VAR PAIR (JS:FUNCALL BAR))
(JS:IF (JS:!== PAIR NIL)
(JS:BLOCK (JS:VAR A (JS:AREF PAIR 0)) (JS:VAR B (JS:AREF PAIR 1))
(JS:IF (JS:! (JS:|\|\|| (JS:=== A NIL) (JS:=== B NIL)))
(JS:BLOCK (JS:VAR VAL (JS:FUNCALL BAZ A B))
(JS:IF (JS:!== VAL NIL)
(JS:IF (JS:FUNCALL BLAH VAL)
(JS:IF (JS:! (JS:FUNCALL BLEE))
(JS:BLOCK (JS:RETURN T)))))))))))))))
As you can see, all you need is to define some functions and macros,
and the resulting code is ready to be EVALed or compiled.
> Go, Vladimir, go! That's an ambitious project but I would love to see it
> printer already. See http://github.com/gonzojive/js-parser
> included a pretty printer and an obfuscating printer that would obfuscate
> extra syntax additions.
> everything, but you should be able to avoid writing the parser yourself, at
> the very least.
Thanks for the pointer. I didn't know you based your parser on JWACS'.
I took a look at JWACS when starting, but decided to base mine on
Marijn Haverbeke's parse-js (http://marijn.haverbeke.nl/parse-js/);
it seemed easier to modify.
>> One user-visible change I made in the latest patches is to encourage
>> use of CL equality predicates ('==' and '===' are still there but
>> marked as deprecated).
>> 2010/4/19 John Pallister <john at synchromesh.com>:
>> > +1, as they say...
>> > ++Thanks,
>> > John :^P
>> > On Mon, Apr 19, 2010 at 12:42 AM, Daniel Gackle <danielgackle at gmail.com>
>> > wrote:
>> >> For those of us who are curious, could you talk a bit about the work
>> >> you did
>> >> on the compiler?
>> >> Thanks Vladimir,
>> >> Daniel
>> > _______________________________________________
>> > parenscript-devel mailing list
>> > parenscript-devel at common-lisp.net
>> > http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
>> parenscript-devel mailing list
>> parenscript-devel at common-lisp.net
> parenscript-devel mailing list
> parenscript-devel at common-lisp.net
More information about the parenscript-devel