Hello, Yesterday I posted some code that implements closures with parameters. A closure in an even purer sense is simply some code that runs in an associated environment. Parametric closures are more complex in that they establish a new scope, bind arguments to parameters, and finally execute the code in that environment. So let's look at the simple case of code that runs in an environment. It's implemented below in "simple-closures.factor".
Ed ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! simple-closures.factor ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! USING: kernel namespaces ; IN: simple-closures ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! TUPLE: closure namestack quot ; : make-closure ( quot -- closure ) namestack swap <closure> ; : call-closure ( closure -- ) namestack >r dup closure-namestack set-namestack closure-quot call r> set-namestack ; ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Factor-talk mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/factor-talk
