2007-09-20 18:09:08 -04:00
|
|
|
|
2008-09-10 23:11:40 -04:00
|
|
|
USING: kernel parser math quotations namespaces sequences macros
|
|
|
|
bake bake.fry ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
IN: rewrite-closures
|
|
|
|
|
|
|
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
|
2008-07-01 10:31:52 -04:00
|
|
|
: [set-parameters] ( seq -- quot ) reverse [ [ set ] curry ] map concat ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-07-01 10:31:52 -04:00
|
|
|
MACRO: set-parameters ( seq -- quot ) [set-parameters] ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-07-01 10:31:52 -04:00
|
|
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-06-30 13:09:05 -04:00
|
|
|
: parametric-quot ( parameters quot -- quot ) '[ , set-parameters , call ] ;
|
|
|
|
|
2008-07-01 10:31:52 -04:00
|
|
|
: scoped-quot ( quot -- quot ) '[ , with-scope ] ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
: closed-quot ( quot -- quot )
|
2008-06-30 17:29:20 -04:00
|
|
|
namestack swap '[ namestack [ , set-namestack @ ] dip set-namestack ] ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
|
2008-06-30 17:29:20 -04:00
|
|
|
: lambda ( parameters quot -- quot ) parametric-quot scoped-quot closed-quot ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
|
|
|
|
: C[ \ ] [ >quotation ] parse-literal \ closed-quot parsed ; parsing
|