1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-21 10:37:58 +03:00
mal/pil/env.l
Vasilij Schneidermann 1809f9baba Fix error handling
2016-10-22 12:37:24 +02:00

25 lines
597 B
Plaintext

(class +Env)
# data outer
(dm T (Outer Binds Exprs)
(=: data (new))
(=: outer Outer)
(for (Binds Binds Binds)
(if (<> (car Binds) '&)
(set> This (pop 'Binds) (pop 'Exprs))
(pop 'Binds)
(set> This (pop 'Binds) (MAL-list Exprs)) ) ) )
(de MAL-env (Outer Binds Exprs)
(new '(+Env) Outer Binds Exprs) )
(dm set> (Key Value)
(put (: data) Key Value) )
(dm find> (Key)
(or (get (: data) Key)
(and (: outer) (find> @ Key)) ) )
(dm get> (Key)
(or (find> This Key)
(throw 'err (MAL-error (MAL-string (pack "'" Key "' not found")))) ) )