Paste: free-vars (current)
Author: | dharmatech |
Mode: | factor |
Date: | Thu, 20 Nov 2008 08:40:04 |
Plain Text |
GENERIC: free-vars* ( form -- )
: free-vars ( form -- vars )
[ free-vars* ] { } make prune ;
: add-if-free ( object -- )
{
{ [ dup local-writer? ] [ "local-reader" word-prop , ] }
{ [ dup lexical? ] [ , ] }
{ [ dup quote? ] [ local>> , ] }
{ [ t ] [ free-vars* ] }
} cond ;
M: object free-vars* drop ;
M: quotation free-vars* [ add-if-free ] each ;
M: lambda free-vars*
[ vars>> ] [ body>> ] bi free-vars swap diff % ;
New Annotation