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)
The reason that heuristic is there is to support really deep nested IF statements like http://lists.common-lisp.net/pipermail/parenscript-devel/2009-December/00069...
I'll see what I can do about "doing the right thing" with deep nested IFs without using the printer.
Vladimir
On Wed, Aug 31, 2011 at 5:39 PM, sblist@me.com wrote:
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) -- 1.7.6
parenscript-devel mailing list parenscript-devel@common-lisp.net http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
Hi Scott,
This issue has been fixed in one of the patches I just pushed. The compiler no longer calls out to the printer twice.
Vladimir
On Wed, Aug 31, 2011 at 5:39 PM, sblist@me.com wrote:
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) -- 1.7.6
parenscript-devel mailing list parenscript-devel@common-lisp.net http://lists.common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
parenscript-devel@common-lisp.net