Skip to content

Commit

Permalink
version 9.2 enhance and correct for next step allowing break to retur…
Browse files Browse the repository at this point in the history
…n a value
  • Loading branch information
damien-mattei committed Sep 13, 2024
1 parent 151754f commit b652b3b
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 38 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<p style="text-align: center;"><br>
</p>
<h1 style="text-align: center;"><b><span style="color: #000099;">Scheme+</span></b><b><span
style="color: #999999;"> <font size="+2">version 9.1.1 for Guile Scheme<br>
style="color: #999999;"> <font size="+2">version 9.2 for Guile Scheme<br>
</font></span></b></h1>
<p style="text-align: center;">
Display options for viewing this documentation:<br>
Expand Down
2 changes: 1 addition & 1 deletion Scheme+.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h2 style=" text-align: center;">Damien Mattei<br>
<p style="text-align: center;"><br>
</p>
<h1 style="text-align: center;"><b><span style="color: #000099;">Scheme+</span></b><b><span
style="color: #999999;"> <font size="+2">version 9.1.1 for Guile Scheme<br>
style="color: #999999;"> <font size="+2">version 9.2 for Guile Scheme<br>
</font></span></b></h1>
<p style="text-align: center;"> </p>
<p style="text-align: center;"><br>
Expand Down
2 changes: 1 addition & 1 deletion Scheme+.scm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;; Scheme+.scm

;; version 9.1.1
;; version 9.2

;; author: Damien MATTEI

Expand Down
2 changes: 1 addition & 1 deletion Scheme+io.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ <h2 style=" text-align: center;">Damien Mattei<br>
no room for doubts must have no room for thoughts either."</i> -<a href="https://www.ics.uci.edu/%7Epattis/" target="_blank">R. Patti</a></p>
<p style="text-align: center;"><br>
</p>
<h1 style="text-align: center;"><b><span style="color: #000099;">Scheme+</span></b><b><span style="color: #999999;"> <font size="+2">version 9.1.1 for Guile Scheme<br>
<h1 style="text-align: center;"><b><span style="color: #000099;">Scheme+</span></b><b><span style="color: #999999;"> <font size="+2">version 9.2 for Guile Scheme<br>
</font></span></b></h1>
<p style="text-align: center;">
Display options for viewing this documentation:<br><br>
Expand Down
3 changes: 3 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ clean code
add more infix without { } in do while / repeat until / ... ?
in $nfx$ see TODO
syntax in def.scm and in overload
make it with sub modules of Scheme+ submodule
modify for next step as racket version

3 changes: 2 additions & 1 deletion bracket-apply.scm
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@

(with-syntax ((parsed-args ;;#`(list #,@(parse-square-brackets-arguments-lister-syntax #`(#,@#'args-brackets)))))

(cons #'list
(cons #'list ; list : cause ERROR in start-λογικι-guile+.scm (logic-test) : ice-9/boot-9.scm:1685:16: In procedure raise-exception:
;; In procedure variable-ref: Unbound variable: #<variable 785f3e25c8f0 value: #<undefined>>
(parse-square-brackets-arguments-lister-syntax #'(arg-bracket ...))))) ; #`(#,@#'args-brackets)))))

(display "$bracket-apply$ : #'parsed-args=") (display #'parsed-args) (newline)
Expand Down
87 changes: 58 additions & 29 deletions for_next_step.scm
Original file line number Diff line number Diff line change
Expand Up @@ -426,39 +426,68 @@
;; 0
;; 1
;; 2
(define-syntax for
(lambda (stx)
(syntax-case stx ()
((kwd (init test incrmt) body ...)
(with-syntax ((BREAK (datum->syntax (syntax kwd) 'break))
(CONTINUE (datum->syntax (syntax kwd) 'continue)))
;; (define-syntax for
;; (lambda (stx)
;; (syntax-case stx ()
;; ((kwd (init test incrmt) body ...)
;; (with-syntax ((BREAK (datum->syntax (syntax kwd) 'break))
;; (CONTINUE (datum->syntax (syntax kwd) 'continue)))

(syntax
;;(let ()
(call/cc
(lambda (escape)
;;init
(let-syntax ((BREAK (identifier-syntax (escape))))
;; (syntax
;; ;;(let ()
;; (call/cc
;; (lambda (escape)
;; ;;init
;; (let-syntax ((BREAK (identifier-syntax (escape))))

init
(let loop ((res 0)) ;; now we will return a result at the end if no break but if we continue? what happens?
(if test
(begin
(call/cc
(lambda (next)
(set! res (let-syntax ((CONTINUE (identifier-syntax (next))))
(let () ;; allow definitions
body ...)))))
incrmt
(loop res))
res)
))))
;;) ; close (let () ...
;; init
;; (let loop ((res 0)) ;; now we will return a result at the end if no break but if we continue? what happens?
;; (if test
;; (begin
;; (call/cc
;; (lambda (next)
;; (set! res (let-syntax ((CONTINUE (identifier-syntax (next))))
;; (let () ;; allow definitions
;; body ...)))))
;; incrmt
;; (loop res))
;; res)
;; ))))
;; ;;) ; close (let () ...

) ; close syntax
;; ) ; close syntax

) ; close with-syntax
))))
;; ) ; close with-syntax
;; ))))



(define-syntax for

(lambda (stx)

(syntax-case stx ()

((_ (init test incrmt) body ...)

(with-syntax ((BREAK (datum->syntax stx 'break))
(CONTINUE (datum->syntax stx 'continue)))
(syntax
(call/cc
(lambda (escape)
(let ((BREAK escape))
init
(let loop ()
(when test
(call/cc
(lambda (next)
(let ((CONTINUE next))
(let () ;; allow definitions
body ...)))) ; end call/cc
incrmt
(loop))) ; end let loop
))))) ;; close with-syntax
))))


;; (for/bc ({k <+ 0} {k < 3} {k <- {k + 1}})
Expand Down
2 changes: 1 addition & 1 deletion infix-with-precedence-to-prefix.scm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
;;; evaluates `terms` symbolically or numerically as a basic infix expression
(define (!0-generic terms operator-precedence creator)

;; (display "!0-generic : terms=") (display terms) (newline)
;;(display "!0-generic : terms=") (display terms) (newline)
;; (display "!0-generic : operator-precedence=") (display operator-precedence) (newline)

(define rv
Expand Down
7 changes: 4 additions & 3 deletions nfx.scm
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,15 @@
;; TODO : make n-arity for <- and <+ only (because could be false with ** , but not implemented in n-arity for now)


(n-arity ;; this avoid : '{x <- y <- z <- t <- u <- 3 * 4 + 1}
(n-arity ;; this avoids : '{x <- y <- z <- t <- u <- 3 * 4 + 1}
;; SRFI-105.scm : !0 result = (<- (<- (<- (<- (<- x y) z) t) u) (+ (* 3 4) 1)) ;; fail set! ...
;; transform in : '(<- x y z t u (+ (* 3 4) 1))
(!0-generic #'(e1 op1 e2 op2 e3 op ...) ; apply operator precedence rules
infix-operators-lst-for-parser-syntax
(lambda (op a b) (list op a b))))))
(display "$nfx$ : parsed-args=") (display #'parsed-args) (newline)
#'parsed-args)))))

(display "$nfx$ : parsed-args=") (display #'parsed-args) (newline)
#'parsed-args)))))



Expand Down

0 comments on commit b652b3b

Please sign in to comment.