Verified Commit c202f5d0 authored by Vladimir Sedach's avatar Vladimir Sedach
Browse files

Deprecated WHILE special form in favor of LOOP WHILE

parent e6489e09
......@@ -1307,7 +1307,6 @@ someDiv.offsetLeft;</samp></pre>
<li>(<code id="dotimes">DOTIMES</code> (<var>var</var> <var>numeric-form</var> {<var>result</var>}?) <var>body</var>)</li>
<li>(<code id="dolist">DOLIST</code> (<var>var</var> <var>list-form</var> {<var>result</var>}?) <var>body</var>)</li>
<li>(<code id="for-in">FOR-IN</code> (<var>var</var> <var>object</var>) <var>body</var>)</li>
<li>(<code id="while">WHILE</code> <var>end-test</var> <var>body</var>)</li>
<li>(<code id="loop">LOOP</code> {&lt;loop clauses&gt;}*)</li>
</ul>
......@@ -1568,6 +1567,6 @@ someDiv.offsetLeft;</samp></pre>
function argument lists to the Emacs minibuffer, like SLIME
already does for Common Lisp functions and macros.</p>
<p style="font-size:xx-small;float:right;">Last updated: 2018-10-20</p>
<p style="font-size:xx-small;float:right;">Last updated: 2018-10-24</p>
</body>
</html>
......@@ -146,7 +146,16 @@ is output to the OUTPUT-STREAM stream."
(define-statement-operator with (expression &rest body)
(warn-deprecated 'with '|LET or WITH-SLOTS|)
`(ps-js:with ,(compile-expression expression)
,(compile-statement `(progn ,@body))))
,(compile-statement `(progn ,@body))))
(define-statement-operator while (test &rest body)
(warn-deprecated 'while '|LOOP WHILE|)
`(ps-js:while ,(compile-expression test)
,(compile-loop-body () body)))
(defmacro while (test &body body)
(warn-deprecated 'while '|LOOP WHILE|)
`(loop while ,test do (progn ,@body)))
(defpsmacro label (&rest args)
(warn-deprecated 'label 'block)
......
......@@ -118,7 +118,7 @@
#:block
#:break
#:continue
#:do-while
#:do-while ; currently unused
#:for
#:for-in
#:if
......
......@@ -407,10 +407,14 @@
(t `((bind ,place ,expr ,@body)))))))
body)))))
(define-statement-operator loop-while (test &rest body)
`(ps-js:while ,(compile-expression test)
,(compile-loop-body () body)))
(defun master-loop (master-iter body)
(destructuring-bind (tag place init step test &optional js-obj) master-iter
(assert (eq tag :iter))
(cond ((null place) `(while ,test ,@body))
(cond ((null place) `(loop-while ,test ,@body))
(js-obj
(assert (not (or init step test)) nil "Unexpected iteration state in for..in loop: ~a" master-iter)
`(for-in (,place ,js-obj) ,@body))
......
......@@ -185,13 +185,6 @@
,(compile-expression object)
,(compile-loop-body (list var) body)))
(define-statement-operator while (test &rest body)
`(ps-js:while ,(compile-expression test)
,(compile-loop-body () body)))
(defmacro while (test &body body)
`(loop while ,test do (progn ,@body)))
;;; misc
(define-statement-operator try (form &rest clauses)
......
......@@ -602,11 +602,13 @@ for (var i in obj) {
})();")
(test-ps-js iteration-constructs-9
(while ((@ film is-not-finished))
((@ this eat) (new *popcorn)))
"while (film.isNotFinished()) {
(loop while (funcall (@ film is-not-finished)) do
(funcall (@ this eat) (new *popcorn)))
"(function () {
while (film.isNotFinished()) {
this.eat(new Popcorn);
};")
};
}).call(this);")
(test-ps-js loop-for-bindings
(loop :for ((a b) (:c :d)) :in arr :do (foo a b c d))
......@@ -3390,17 +3392,19 @@ for (var i = 0; i < 10; i += 1) {
})();")
(test-ps-js while-closures-let
(while (foo)
(loop while (foo) do
(let ((abc (bar)))
(lambda () (+ 1 abc))))
"while (foo()) {
"(function () {
while (foo()) {
(function () {
var abc = bar();
return function () {
return 1 + abc;
};
})();
};")
};
})();")
(test-ps-js dotted-list-form
(defun foo (a)
......@@ -3848,7 +3852,7 @@ return function (x) {
})());")
(test-ps-js trivial-expression-while
(foobar (while (< 0 x) (decf x)))
(foobar (loop while (< 0 x) do (decf x)))
"foobar((function () {
while (0 < x) {
--x;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment