mirror of
https://github.com/kanaka/mal.git
synced 2024-09-21 02:27:10 +03:00
25 lines
597 B
Plaintext
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")))) ) )
|