Hello,
I have a problem with the Parenscript from the latest Quicklisp update (2012-02-08).
Before this update: I'm trying to instantiate an object using 'new'. Since I wanted to have 'var obj = new ClassName();' and not 'var obj = new ClassName' I used '(ps ((new -class-name)))' which did what I wanted (generate 'new ClassName()').
After the update: '(ps ((new -class-name)))' generates '(new ClassName)()' which is wrong. Luckily for me, 'new ClassName' generated by '(new -class-name)' works.
What do I do if I need to generate something like 'new Person(age, shoeSize)'? (i.e. I don't know how to pass parameters to new - and I could not find a description of any special syntax in the manual). '(ps (new -person age shoe-size))', fails with an error which seems to imply that there can be only one argument to new (when printing :-) ).
I managed to convince the printer to accept '(ps (new -person age shoe-size))' and generate 'new Person(age, shoeSize)' using the code in this patch:
diff --git a/src/printer.lisp b/src/printer.lisp index c37e10c..d7e26f4 100644 --- a/src/printer.lisp +++ b/src/printer.lisp @@ -235,7 +235,14 @@ vice-versa.") (defprinter ps-js:negate (x) "-"(print-op-argument op x))
-(defprinter (ps-js:delete ps-js:typeof ps-js:new ps-js:throw) (x) +(defprinter ps-js:new (&rest x) + "new " + (ps-print (car x)) + "(" + (psw (format nil "~{~a~^, ~}" (mapcar #'symbol-to-js-string (cdr x)))) + ")") + +(defprinter (ps-js:delete ps-js:typeof ps-js:throw) (x) (print-op op)" "(print-op-argument op x))
(defprinter (ps-js:return) (&optional (x nil x?))
Thanks for any suggestions,