smalltalk: whileTrue:/whileFalse: family pinned + 14 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled

This commit is contained in:
2026-04-25 04:24:27 +00:00
parent f09a712666
commit a7272ad162
3 changed files with 166 additions and 18 deletions

View File

@@ -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 —