2 module Environment
= struct
3 (**********************************************************************
5 **********************************************************************)
6 let push_env_frame env formals actuals
=
8 let h = Hashtbl.create
(List.length formals
) in
10 (function (name
, obj
) -> Hashtbl.add
h name obj
)
11 (List.combine formals actuals
);
15 let find_frame env k
=
17 List.find
(fun x
-> Hashtbl.mem x k
) env
19 Not_found
-> raise
(Scheme_eval_error
("undefined: "^k
));;
23 Hashtbl.find
(find_frame env k
) k
25 Not_found
-> raise
(Scheme_eval_error
("undefined: "^k
));;
29 Hashtbl.replace
(find_frame env k
) k v
31 Not_found
-> raise
(Scheme_eval_error
("undefined: "^k
));;
33 let current_env_frame = function
38 let initial_env = [Hashtbl.create
1]