 
 DEFER: convert-form
 DEFER: funcall
-DEFER: lookup-vars
+DEFER: lookup-var
 
 ! Functions to convert s-exps to quotations
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

: rest-lambda ( body vars -- quot )  
  "&rest" swap [ remove ] [ index ] 2bi
  [ localize-lambda <lambda> ] dip
  [ , lookup-vars cut swap [ % , ] bake , compose ] bake ;
  
: normal-lambda ( body vars -- quot )
  localize-lambda <lambda> [ lookup-vars , compose ] bake ;
PRIVATE>
  
: convert-lambda ( s-exp -- quot )  

    [ drop convert-general-form ] if ;
  
: convert-form ( lisp-form -- quot )
  { { [ dup s-exp? ] [ body>> convert-list-form ] }
    { [ dup lisp-symbol? ] [ [ , lookup-var ] bake ] }
    [ [ , ] bake ]
  } cond ;
                
: lisp-string>factor ( str -- quot )
  lisp-expr parse-result-ast convert-form lambda-rewrite call ;
