[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
for with break and continue
From: |
Damien Mattei |
Subject: |
for with break and continue |
Date: |
Sun, 4 Sep 2022 11:54:00 +0200 |
i try to make a for with break and continue the way C language do it, i
works with break but if i add a continue feature i then loose the break
feature, here is my code:
(define-syntax for/bc
(lambda (stx)
(syntax-case stx ()
((kwd (init test incrmt) body ...)
(with-syntax
((BREAK (datum->syntax #'kwd 'break)))
#'(call/cc
(lambda (escape)
(let-syntax
((BREAK (identifier-syntax (escape))))
init
(let loop ()
(when test
(with-syntax
((CONTINUE (datum->syntax #'kwd 'continue)))
#'(call/cc
(lambda (next)
(let-syntax
((CONTINUE (identifier-syntax (next))))
body ...)))
incrmt
(loop))))))))))))
Damien
- for with break and continue,
Damien Mattei <=