i finalize my ideas about 'controls' and loops (with break and continue, as while feature them ,even if scheme and macro do not allow ? (if someone else have idea and solution about it?) implements of 'continue and 'break because hygiene forbid it) https://github.com/damien-mattei/library-FunctProg/blob/master/while-do-when-unless.scm
;; scheme@(guile-user)> (for/break-cont break continue ({i <+ 0} {i < 5} {i <- {i + 1}}) {x <+ 7} (display x) (newline)) ;; 7 ;; 7 ;; 7 ;; 7 ;; 7 ;; scheme@(guile-user)> (for/break-cont break continue ({i <+ 0} {i < 5} {i <- {i + 1}}) {x <+ 7} (display x) (newline) (break)) ;;7 ;; scheme@(guile-user)> (for/break-cont break continue ({i <+ 0} {i < 5} {i <- {i + 1}}) {x <+ 7} (continue) (display x) (newline) (break)) (define-syntax for/break-cont (syntax-rules () ((_ <break-id> <continue-id> (init test incrmt) b1 ...) (call/cc (lambda (<break-id>) (let () init (let loop () (when test (call/cc (lambda (<continue-id>) b1 ...)) incrmt (loop))))))))) https://github.com/damien-mattei/library-FunctProg/blob/master/for-next-step.scm Damien On Thu, Sep 1, 2022 at 10:21 PM Damien Mattei <damien.mat...@gmail.com> wrote: > On Wed, Aug 31, 2022 at 5:29 PM Maxime Devos <maximede...@telenet.be> > wrote: > >> >> On 31-08-2022 09:01, Damien Mattei wrote: >> > I always try to keep compatibility with RnRS and in fact except cond >> > none of when, unless, cond, case, while, and do are in standart RnRS >> schem >> >> 'when', 'unless' and 'do' are actually RnRS, see (rnrs control). >> > > oh your're right...i was sticked to R5RS ,time i was student... > >> >> 'case' is also RnRS, see (rnrs base). >> >> However, looking at (guile)while do, 'while' is indeed non-standard. >> > > and i had rewritten last week a 'while ... do' like in C or Pascal: > https://www.tutorialspoint.com/pascal/pascal_while_do_loop.htm > https://www.tutorialspoint.com/cprogramming/c_while_loop.htm > > in my Scheme+: > > ;; (define do '()) > ;; (while {i < 4} > ;; do > ;; (display i) > ;; (newline) > ;; {i <- {i + 1}}) > ;; 0 > ;; 1 > ;; 2 > ;; 3 > ;; $1 = #f > (define-syntax while > (syntax-rules (while do) > ((_ pred do b1 ...) > (let loop () (when pred b1 ... (loop)))))) > > i will have to forget it! as i want to keep compatibility with standard > Scheme also but i will rewrite all with (let () ...) instead of (begin ...) > unless it can cause some incompatibilities, for now , i do not see problems > as "who can do more can do less"...... > > Regards, > Damien > >> >>