smalltalk: whileTrue:/whileFalse: family pinned + 14 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
This commit is contained in:
@@ -446,27 +446,29 @@
|
||||
temps)
|
||||
(st-eval-seq body frame))))))))
|
||||
|
||||
;; whileTrue: / whileTrue / whileFalse: / whileFalse — the receiver is the
|
||||
;; condition block; the optional argument is the body block. Per ANSI / Pharo
|
||||
;; convention, the loop returns nil regardless of how many iterations ran.
|
||||
(define
|
||||
st-block-while
|
||||
(fn
|
||||
(cond-block body-block target)
|
||||
(let ((last nil))
|
||||
(begin
|
||||
(define
|
||||
wh-loop
|
||||
(fn
|
||||
()
|
||||
(let
|
||||
((c (st-block-apply cond-block (list))))
|
||||
(when
|
||||
(= c target)
|
||||
(begin
|
||||
(cond
|
||||
((not (= body-block nil))
|
||||
(set! last (st-block-apply body-block (list)))))
|
||||
(wh-loop))))))
|
||||
(wh-loop)
|
||||
last))))
|
||||
(begin
|
||||
(define
|
||||
wh-loop
|
||||
(fn
|
||||
()
|
||||
(let
|
||||
((c (st-block-apply cond-block (list))))
|
||||
(when
|
||||
(= c target)
|
||||
(begin
|
||||
(cond
|
||||
((not (= body-block nil))
|
||||
(st-block-apply body-block (list))))
|
||||
(wh-loop))))))
|
||||
(wh-loop)
|
||||
nil)))
|
||||
|
||||
;; ── Primitive method table for native receivers ────────────────────────
|
||||
;; Returns the result, or the sentinel :unhandled if no primitive matches —
|
||||
|
||||
Reference in New Issue
Block a user