new macro: ret

http://arclanguage.org/item?id=11068
This commit is contained in:
Kartik K. Agaram 2021-06-20 21:35:02 -07:00
parent deb610367f
commit ecc763f092

View File

@ -18,6 +18,8 @@
(list . [def (list . args) (list . [def (list . args)
# we should probably make a copy here # we should probably make a copy here
args]) args])
(ret . [mac (ret var val . body)
`(let ,var ,val ,@body ,var)])
(len . [def (len l) (len . [def (len l)
if (no l) if (no l)
0 0
@ -125,12 +127,11 @@
dx dx
0)))))))))))]) 0)))))))))))])
(read_line . [def (read_line keyboard) (read_line . [def (read_line keyboard)
(let str (stream) ret str (stream)
(let c (key keyboard) let c (key keyboard)
(while (not (or (= c 0) (= c 10))) while (not (or (= c 0) (= c 10)))
(write str c) (write str c)
(set c (key keyboard)))) (set c (key keyboard))])
str)])
(wait . [def (wait keyboard) (wait . [def (wait keyboard)
while (= 0 (key keyboard)) while (= 0 (key keyboard))
()]) ()])