[parenscript-devel] Symbol-macrolet bug

Vladimir Sedach vsedach at gmail.com
Thu Sep 20 23:13:42 UTC 2007


For everyone's reference, here's the definition of @:

(defpsmacro @ (obj &rest props)
    (if (null props)
	obj
	`(@ (slot-value
	     ,(if (stringp obj) `($ ,obj) obj)
	     ,(let ((prop (macroexpand (first props))))
		   (if (symbolp prop)
		       `',prop
		       prop)))
	    ,@(cdr props))))

It's a macro whose idea Daniel borrowed from Peter Seibel's Lispscript
Lisp-to-JavaScript compiler, and does things like (ps (@ foo "bar" 3
baz)) => foo['bar'][3].baz;. I will probably include it in the
ParenScript helper library someday when I am unlazy enough to write
the documentation.

That being said, the behavior demonstrated is a feature, not a bug.
The macros are being expanded in the right order (that is, same order
as Common Lisp does it). Consider the following Common Lisp code:

(defmacro foo (x) (format nil "~a" x))

(foo bar) => "BAR"

(symbol-macrolet ((bar 1)) (list (foo bar) bar)) => ("BAR" 1)

Vladimir

On 9/12/07, Daniel Gackle <danielgackle at gmail.com> wrote:
> This works correctly:
>
>    (ps (symbol-macrolet ((blah "y"))
>       (setf (aref x blah) 123)))
>
>      => "x['y'] = 123;"
>
> ... while it appears this does not:
>
>    (ps (symbol-macrolet ((blah "y"))
>      (setf (@ x blah) 123)))
>
>    => "x.blah = 123;"
>
> Daniel
>
> _______________________________________________
> parenscript-devel mailing list
> parenscript-devel at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
>
>



More information about the parenscript-devel mailing list