Created
March 9, 2016 00:11
-
-
Save SYZYGY-DEV333/5d8c829438f283659b2d to your computer and use it in GitHub Desktop.
Simple while loop macro in Chicken Scheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Chicken Scheme | |
;; While Macro in Chicken Scheme | |
;; SYZYGY-DEV333 | |
;; Apache v2 | |
(define-syntax loop | |
(ir-macro-transformer | |
(lambda (expr inject compare) | |
(let ((body (cdr expr))) | |
`(call-with-current-continuation | |
(lambda (,(inject 'exit)) | |
(let f () ,@body (f)))))))) | |
(define-syntax while | |
(ir-macro-transformer | |
(lambda (expr inject compare) | |
(let ((test (cadr expr)) | |
(body (cddr expr))) | |
`(loop | |
(if (not ,test) (,(inject 'exit) #f)) | |
,@body))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simple While Loop Macro in Chicken Scheme
Syntax:
Pointless Example:
Have fun!