diff --git a/impls/ps/step8_macros.ps b/impls/ps/step8_macros.ps index f6fe0290..b7996680 100644 --- a/impls/ps/step8_macros.ps +++ b/impls/ps/step8_macros.ps @@ -160,11 +160,10 @@ end } def env /loop? true def % loop }{ /defmacro! a0 eq { %if defmacro! - /a1 ast 1 _nth def - /a2 ast 2 _nth def - a2 env EVAL - dup /macro? true put % set macro flag - env exch a1 exch env_set % def! it + env + ast 1 _nth + ast 2 _nth env EVAL _macro + env_set }{ /macroexpand a0 eq { %if defmacro! ast 1 _nth env macroexpand }{ /do a0 eq { %if do diff --git a/impls/ps/step9_try.ps b/impls/ps/step9_try.ps index 9cca137d..e13f2a8a 100644 --- a/impls/ps/step9_try.ps +++ b/impls/ps/step9_try.ps @@ -160,11 +160,10 @@ end } def env /loop? true def % loop }{ /defmacro! a0 eq { %if defmacro! - /a1 ast 1 _nth def - /a2 ast 2 _nth def - a2 env EVAL - dup /macro? true put % set macro flag - env exch a1 exch env_set % def! it + env + ast 1 _nth + ast 2 _nth env EVAL _macro + env_set }{ /macroexpand a0 eq { %if defmacro! ast 1 _nth env macroexpand }{ /do a0 eq { %if do diff --git a/impls/ps/stepA_mal.ps b/impls/ps/stepA_mal.ps index 21be2f1b..53c08747 100644 --- a/impls/ps/stepA_mal.ps +++ b/impls/ps/stepA_mal.ps @@ -160,11 +160,10 @@ end } def env /loop? true def % loop }{ /defmacro! a0 eq { %if defmacro! - /a1 ast 1 _nth def - /a2 ast 2 _nth def - a2 env EVAL - dup /macro? true put % set macro flag - env exch a1 exch env_set % def! it + env + ast 1 _nth + ast 2 _nth env EVAL _macro + env_set }{ /macroexpand a0 eq { %if defmacro! ast 1 _nth env macroexpand }{ /ps* a0 eq { %if ps* diff --git a/impls/ps/types.ps b/impls/ps/types.ps index 5edb301f..ad07002b 100644 --- a/impls/ps/types.ps +++ b/impls/ps/types.ps @@ -291,6 +291,16 @@ end } def put % stack: mal_fn } def +% fn -> _defmacro -> macro +/_macro { + dup /ast get exch + dup /env get exch + /params get + _mal_function + dup + /macro? true put +} def + /_function? { dup type /dicttype eq { /_maltype_ get /function eq