# lambda - syntax extension to build embedded contexts # (anonymous functions) # { starts context # } ends context and returns xt in runtime # code stored in link defer { immediate # ( -- xt ) open context and provide closing macro : } execute ; immediate # ( xt -- ) execute closing macro : isbrace r> @ is { ; : brace latestxt read link-word immediate postpone isbrace , ; : next>xt r> dup @ >r follow >xt ; : }, postpone leave postpone then ; : {, postpone next>xt hole, enter, ' }, ; brace lambda lambda # restore orig default # the runtime version. this can be used to store the code on # the return stack and drop it when done. # example: : make-accumulator # ( n -- xt code ) mark ` xxx link enter, postpone literal postpone + postpone leave latestxt mark> ; # this is evil! : make-curried # ( thing xt -- curried.xt code ) [read] curried-word link enter, swap postpone literal xt>ct execute postpone leave latestxt d> # temp-code push "NIKS" ;