PageRenderTime 16ms CodeModel.GetById 10ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 1ms

/kernel/generator.hms

http://github.com/vito/hummus
Unknown | 20 lines | 16 code | 4 blank | 0 comment | 0 complexity | 47a2a32c8feaee8f95c0d1b73fa9f933 MD5 | raw file
 1(provide! (generator)
 2  (defn (aux f)
 3    (define here (get-current-environment))
 4
 5    (defn (start #ignore)
 6      (reset
 7        (lambda (p)
 8          (f (lambda (v)
 9                (shift p
10                  (lambda (k)
11                    (set! here start k)
12                    v)))))))
13
14    (lambda () (start #inert)))
15
16  (define quote (vau (e) #ignore e))
17
18  (define generator
19    (vau body e
20      (eval (list aux (list* lambda (quote (yield)) body)) e))))