[Fix (- 1) and (incf/decf x 5), patch by Ray Myers attila.lendvai@gmail.com**20070427073917 I have a minor patch that fixes the following incorrect (or at least unexpected) behavior in ParenScript. (js (- 1)) => "1;" (js (incf x 5)) => an error (js (decf x 5)) => an error ] { hunk ./src/js.lisp 598 -(define-js-compiler-macro incf (x) - (make-instance 'one-op :pre-p t :op "++" - :value (js-compile-to-expression x))) hunk ./src/js.lisp 601 -(define-js-compiler-macro decf (x) - (make-instance 'one-op :pre-p t :op "--" - :value (js-compile-to-expression x))) + hunk ./src/js.lisp 606 +(define-js-compiler-macro incf (x &optional (delta 1)) + (if (eql delta 1) + (make-instance 'one-op :pre-p t :op "++" + :value (js-compile-to-expression x)) + (make-instance 'op-form + :operator '+= + :args (mapcar #'js-compile-to-expression + (list x delta ))))) + +(define-js-compiler-macro decf (x &optional (delta 1)) + (if (eql delta 1) + (make-instance 'one-op :pre-p t :op "--" + :value (js-compile-to-expression x)) + (make-instance 'op-form + :operator '-= + :args (mapcar #'js-compile-to-expression + (list x delta ))))) + +(define-js-compiler-macro - (first &rest rest) + (if (null rest) + (make-instance 'one-op + :pre-p t + :op "-" + :value (js-compile-to-expression first)) + (make-instance 'op-form + :operator '- + :args (mapcar #'js-compile-to-expression + (cons first rest))))) }