I needed to avoid secondary calls to the printer for the purpose of generating source mappings, but this seems like a more precise definition anyway (unless I've missed something).
Scott
--- src/special-operators.lisp | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/special-operators.lisp b/src/special-operators.lisp index 3a77ae5..be95a5f 100644 --- a/src/special-operators.lisp +++ b/src/special-operators.lisp @@ -130,10 +130,16 @@ `(ps-js:label ,name ,(wrap-block-for-dynamic-return name (compile-statement `(progn ,@body))))))
(defun try-expressionize-if? (form) - (< (count #\Newline (with-output-to-string (*psw-stream*) - (let ((*ps-print-pretty* t)) - (parenscript-print (compile-statement form) t)))) - (if (= (length form) 4) 5 4))) + (destructuring-bind (if condition + (block . consequent) + &optional + else + alternative-block) + (compile-statement form) + (declare (ignore if condition else block)) + (and (= (length consequent) 1) + (or (null alternative-block) + (= (length alternative-block) 2)))))
(define-statement-operator return-from (tag &optional result) (if (not tag)