mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-24 20:45:06 +02:00
Added a (when) macro
This commit is contained in:
parent
63669620de
commit
d4c27b9c63
3 changed files with 12 additions and 1 deletions
3
TODO
3
TODO
|
@ -12,8 +12,9 @@ Working TODO list:
|
||||||
|
|
||||||
- Constructs require for self-hosting
|
- Constructs require for self-hosting
|
||||||
|
|
||||||
- named let
|
|
||||||
- when
|
- when
|
||||||
|
- eval
|
||||||
|
there is no concept of macro expansion, probably other deficiencies as well
|
||||||
|
|
||||||
- vectors
|
- vectors
|
||||||
- make-vector should have an optional 'fill' arg in compiled code
|
- make-vector should have an optional 'fill' arg in compiled code
|
||||||
|
|
|
@ -6,3 +6,7 @@
|
||||||
(if (zero? i)
|
(if (zero? i)
|
||||||
(write 'done)
|
(write 'done)
|
||||||
(loop (- i 1))))
|
(loop (- i 1))))
|
||||||
|
|
||||||
|
|
||||||
|
(write (when (lambda () #t) 'true))
|
||||||
|
(write (when (lambda () #f) 'false))
|
||||||
|
|
|
@ -74,6 +74,12 @@
|
||||||
(error "bad let* syntax")))))
|
(error "bad let* syntax")))))
|
||||||
(cons 'begin (lambda (exp rename compare) (begin=>let exp)))
|
(cons 'begin (lambda (exp rename compare) (begin=>let exp)))
|
||||||
(cons 'letrec (lambda (exp rename compare) (letrec=>lets+sets exp)))
|
(cons 'letrec (lambda (exp rename compare) (letrec=>lets+sets exp)))
|
||||||
|
(cons 'when (lambda (exp rename compare)
|
||||||
|
(if (null? (cdr exp)) (error "empty when" exp))
|
||||||
|
(if (null? (cddr exp)) (error "no when body" exp))
|
||||||
|
`(if ,(cadr exp)
|
||||||
|
((lambda () ,(caddr exp)))
|
||||||
|
#f)))
|
||||||
(cons 'cond
|
(cons 'cond
|
||||||
(lambda (expr rename compare)
|
(lambda (expr rename compare)
|
||||||
(if (null? (cdr expr))
|
(if (null? (cdr expr))
|
||||||
|
|
Loading…
Add table
Reference in a new issue