1
1
mirror of https://github.com/kanaka/mal.git synced 2024-08-17 09:40:21 +03:00

ada: let macros use a closure instead of current env

This commit is contained in:
Nicolas Boulenguez 2021-08-13 08:36:32 +02:00 committed by Joel Martin
parent 022e4f0b51
commit b204bb1f02
3 changed files with 7 additions and 9 deletions

View File

@ -65,7 +65,6 @@ procedure Step8_Macros is
begin
Res := Ast;
E := Env;
loop
@ -77,7 +76,7 @@ procedure Step8_Macros is
-- Get the macro in the list from the env
-- or return null if not applicable.
LP := Get_Macro (Res, E);
LP := Get_Macro (Res, Env);
exit when LP = null or else not LP.Get_Is_Macro;
@ -85,7 +84,7 @@ procedure Step8_Macros is
Fn_List : Mal_Handle := Cdr (LMT);
Params : List_Mal_Type;
begin
E := Envs.New_Env (E);
E := Envs.New_Env (LP.Get_Env);
Params := Deref_List (LP.Get_Params).all;
if Envs.Bind (E, Params, Deref_List (Fn_List).all) then

View File

@ -65,7 +65,6 @@ procedure Step9_Try is
begin
Res := Ast;
E := Env;
loop
@ -77,7 +76,7 @@ procedure Step9_Try is
-- Get the macro in the list from the env
-- or return null if not applicable.
LP := Get_Macro (Res, E);
LP := Get_Macro (Res, Env);
exit when LP = null or else not LP.Get_Is_Macro;
@ -85,7 +84,7 @@ procedure Step9_Try is
Fn_List : Mal_Handle := Cdr (LMT);
Params : List_Mal_Type;
begin
E := Envs.New_Env (E);
E := Envs.New_Env (LP.Get_Env);
Params := Deref_List (LP.Get_Params).all;
if Envs.Bind (E, Params, Deref_List (Fn_List).all) then

View File

@ -65,7 +65,6 @@ procedure StepA_Mal is
begin
Res := Ast;
E := Env;
loop
@ -77,7 +76,7 @@ procedure StepA_Mal is
-- Get the macro in the list from the env
-- or return null if not applicable.
LP := Get_Macro (Res, E);
LP := Get_Macro (Res, Env);
exit when LP = null or else not LP.Get_Is_Macro;
@ -85,9 +84,10 @@ procedure StepA_Mal is
Fn_List : Mal_Handle := Cdr (LMT);
Params : List_Mal_Type;
begin
E := Envs.New_Env (E);
E := Envs.New_Env (LP.Get_Env);
Params := Deref_List (LP.Get_Params).all;
if Envs.Bind (E, Params, Deref_List (Fn_List).all) then
Res := Eval (LP.Get_Expr, E);