]> gitweb.factorcode.org Git - factor.git/commitdiff
Some fixes for cond
authorJames Cash <james.nvc@gmail.com>
Wed, 18 Jun 2008 19:09:02 +0000 (15:09 -0400)
committerJames Cash <james.nvc@gmail.com>
Sun, 24 Aug 2008 03:13:24 +0000 (23:13 -0400)
extra/lisp/lisp.factor

index 0f44286ac97b0adb37d07069c478b9e309f9524b..15b8b15b91cb12066e14e2a4102962448e32926a 100644 (file)
@@ -12,7 +12,6 @@ DEFER: lookup-var
 DEFER: lookup-macro
 DEFER: lisp-macro?
 DEFER: lisp-var?
-DEFER: macro-expand
 DEFER: define-lisp-macro
     
 ! Functions to convert s-exps to quotations
@@ -24,7 +23,7 @@ DEFER: define-lisp-macro
     cdr [ convert-form ] [ ] lmap-as '[ , [ call ] each ] ;
     
 : convert-cond ( cons -- quot )  
-    cdr [ 2car [ convert-form ] bi@ [ '[ @ call ] ] dip 2array ]
+    cdr [ 2car [ convert-form ] bi@ 2array ]
     { } lmap-as '[ , cond ]  ;
     
 : convert-general-form ( cons -- quot )
@@ -64,6 +63,9 @@ PRIVATE>
 : convert-defmacro ( cons -- quot )
     cdr [ car ] keep [ convert-lambda ] [ car name>> ] bi define-lisp-macro 1quotation ;
     
+: macro-expand ( cons -- quot )
+    uncons [ list>seq >quotation ] [ lookup-macro call ] bi* call call convert-form ;
+    
 : form-dispatch ( cons lisp-symbol -- quot )
     name>>
     { { "lambda" [ convert-lambda ] }
@@ -89,9 +91,6 @@ PRIVATE>
      [ 1quotation ]
     } cond ;
     
-: macro-expand ( cons -- quot )
-    uncons [ list>seq >quotation ] [ lookup-macro ] bi* call convert-form call ;
-    
 : lisp-string>factor ( str -- quot )
     lisp-expr compile-form ;
     
@@ -117,10 +116,10 @@ M: no-such-var summary drop "No such variable" ;
     over name>> lisp-define ;
     
 : lisp-get ( name -- word )
-    dup lisp-env get at [ ] [ no-such-var ] ?if ;
+    lisp-env get at ;
     
 : lookup-var ( lisp-symbol -- quot )
-    name>> lisp-get ;
+    [ name>> ] [ lisp-var? ] bi [ lisp-get ] [ no-such-var ] if ;
     
 : lisp-var? ( lisp-symbol -- ? )
     dup lisp-symbol? [ name>> lisp-env get key? ] [ drop f ] if ;