mirror of
https://github.com/kanaka/mal.git
synced 2024-09-11 21:57:38 +03:00
factor: prevent defmacro from mutating functions
This commit is contained in:
parent
7c5d341849
commit
e3c376ebd5
@ -15,9 +15,12 @@ TUPLE: malfn
|
|||||||
{ env malenv read-only }
|
{ env malenv read-only }
|
||||||
{ binds sequence read-only }
|
{ binds sequence read-only }
|
||||||
{ exprs read-only }
|
{ exprs read-only }
|
||||||
{ macro? boolean }
|
{ macro? boolean read-only }
|
||||||
{ meta assoc } ;
|
{ meta assoc } ;
|
||||||
|
|
||||||
|
: malmacro ( fn -- fn )
|
||||||
|
[ env>> ] [ binds>> ] [ exprs>> ] tri t f malfn boa ;
|
||||||
|
|
||||||
: <malfn> ( env binds exprs -- fn )
|
: <malfn> ( env binds exprs -- fn )
|
||||||
f f malfn boa ;
|
f f malfn boa ;
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ M: object eval-ast drop ;
|
|||||||
value env EVAL [ key env env-set ] keep ;
|
value env EVAL [ key env env-set ] keep ;
|
||||||
|
|
||||||
:: eval-defmacro! ( key value env -- maltype )
|
:: eval-defmacro! ( key value env -- maltype )
|
||||||
value env EVAL t >>macro? [ key env env-set ] keep ;
|
value env EVAL malmacro [ key env env-set ] keep ;
|
||||||
|
|
||||||
: eval-let* ( bindings body env -- maltype env )
|
: eval-let* ( bindings body env -- maltype env )
|
||||||
[ swap 2 group ] [ new-env ] bi* [
|
[ swap 2 group ] [ new-env ] bi* [
|
||||||
|
@ -21,7 +21,7 @@ M: object eval-ast drop ;
|
|||||||
value env EVAL [ key env env-set ] keep ;
|
value env EVAL [ key env env-set ] keep ;
|
||||||
|
|
||||||
:: eval-defmacro! ( key value env -- maltype )
|
:: eval-defmacro! ( key value env -- maltype )
|
||||||
value env EVAL t >>macro? [ key env env-set ] keep ;
|
value env EVAL malmacro [ key env env-set ] keep ;
|
||||||
|
|
||||||
: eval-let* ( bindings body env -- maltype env )
|
: eval-let* ( bindings body env -- maltype env )
|
||||||
[ swap 2 group ] [ new-env ] bi* [
|
[ swap 2 group ] [ new-env ] bi* [
|
||||||
|
@ -21,7 +21,7 @@ M: object eval-ast drop ;
|
|||||||
value env EVAL [ key env env-set ] keep ;
|
value env EVAL [ key env env-set ] keep ;
|
||||||
|
|
||||||
:: eval-defmacro! ( key value env -- maltype )
|
:: eval-defmacro! ( key value env -- maltype )
|
||||||
value env EVAL t >>macro? [ key env env-set ] keep ;
|
value env EVAL malmacro [ key env env-set ] keep ;
|
||||||
|
|
||||||
: eval-let* ( bindings body env -- maltype env )
|
: eval-let* ( bindings body env -- maltype env )
|
||||||
[ swap 2 group ] [ new-env ] bi* [
|
[ swap 2 group ] [ new-env ] bi* [
|
||||||
|
Loading…
Reference in New Issue
Block a user