factor: Fix exception on literal empty list
authorDov Murik <dov.murik@gmail.com>
Fri, 1 Apr 2016 20:15:42 +0000 (16:15 -0400)
committerDov Murik <dov.murik@gmail.com>
Fri, 1 Apr 2016 20:15:42 +0000 (16:15 -0400)
Issue #190

factor/step3_env/step3_env.factor
factor/step4_if_fn_do/step4_if_fn_do.factor
factor/step5_tco/step5_tco.factor
factor/step6_file/step6_file.factor
factor/step7_quote/step7_quote.factor
factor/step8_macros/step8_macros.factor
factor/step9_try/step9_try.factor
factor/stepA_mal/stepA_mal.factor

index 9883c3f..3dbdc00 100755 (executable)
@@ -1,9 +1,8 @@
 ! Copyright (C) 2015 Jordan Lewis.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays assocs combinators continuations fry
-grouping hashtables io kernel locals lib.env lib.printer
-lib.reader lib.types math namespaces quotations readline
-sequences ;
+USING: accessors arrays assocs combinators combinators.short-circuit
+continuations fry grouping hashtables io kernel locals lib.env lib.printer
+lib.reader lib.types math namespaces quotations readline sequences ;
 IN: step3_env
 
 CONSTANT: repl-bindings H{
@@ -36,7 +35,7 @@ DEFER: EVAL
 : READ ( str -- maltype ) read-str ;
 
 :: EVAL ( maltype env -- maltype )
-    maltype dup array? [
+    maltype dup { [ array? ] [ empty? not ] } 1&& [
         unclip dup dup malsymbol? [ name>> ] when {
             { "def!" [ drop first2 env eval-def! ] }
             { "let*" [ drop first2 env eval-let* ] }
index 18f79f4..d48f241 100755 (executable)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2015 Jordan Lewis.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays assocs combinators continuations fry
-grouping hashtables io kernel lists locals lib.core lib.env
-lib.printer lib.reader lib.types math namespaces quotations
-readline sequences splitting ;
+USING: accessors arrays assocs combinators combinators.short-circuit
+continuations fry grouping hashtables io kernel lists locals lib.core lib.env
+lib.printer lib.reader lib.types math namespaces quotations readline sequences
+splitting ;
 IN: step4_if_fn_do
 
 SYMBOL: repl-env
@@ -55,7 +55,7 @@ M: callable apply call( x -- y ) ;
 : READ ( str -- maltype ) read-str ;
 
 :: EVAL ( maltype env -- maltype )
-    maltype dup array? [
+    maltype dup { [ array? ] [ empty? not ] } 1&& [
         dup first dup malsymbol? [ name>> ] when {
             { "def!" [ rest first2 env eval-def! ] }
             { "let*" [ rest first2 env eval-let* ] }
index 964abc6..face303 100755 (executable)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2015 Jordan Lewis.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays assocs combinators continuations fry
-grouping hashtables io kernel lists locals lib.core lib.env
-lib.printer lib.reader lib.types math namespaces quotations
-readline sequences splitting ;
+USING: accessors arrays assocs combinators combinators.short-circuit
+continuations fry grouping hashtables io kernel lists locals lib.core lib.env
+lib.printer lib.reader lib.types math namespaces quotations readline sequences
+splitting ;
 IN: step5_tco
 
 SYMBOL: repl-env
@@ -62,7 +62,7 @@ M: callable apply call( x -- y ) f ;
 : READ ( str -- maltype ) read-str ;
 
 : EVAL ( maltype env -- maltype )
-    over array? [
+    over { [ array? ] [ empty? not ] } 1&& [
         over first dup malsymbol? [ name>> ] when {
             { "def!" [ [ rest first2 ] dip eval-def! f ] }
             { "let*" [ [ rest first2 ] dip eval-let* ] }
index a63469d..29d9b4b 100755 (executable)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2015 Jordan Lewis.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays assocs combinators command-line
-continuations fry grouping hashtables io kernel lists locals
-lib.core lib.env lib.printer lib.reader lib.types math
-namespaces quotations readline sequences splitting ;
+USING: accessors arrays assocs combinators combinators.short-circuit
+command-line continuations fry grouping hashtables io kernel lists locals
+lib.core lib.env lib.printer lib.reader lib.types math namespaces quotations
+readline sequences splitting ;
 IN: step6_file
 
 SYMBOL: repl-env
@@ -62,7 +62,7 @@ M: callable apply call( x -- y ) f ;
 : READ ( str -- maltype ) read-str ;
 
 : EVAL ( maltype env -- maltype )
-    over array? [
+    over { [ array? ] [ empty? not ] } 1&& [
         over first dup malsymbol? [ name>> ] when {
             { "def!" [ [ rest first2 ] dip eval-def! f ] }
             { "let*" [ [ rest first2 ] dip eval-let* ] }
index 1c539ba..7609838 100755 (executable)
@@ -75,7 +75,7 @@ M: callable apply call( x -- y ) f ;
 : READ ( str -- maltype ) read-str ;
 
 : EVAL ( maltype env -- maltype )
-    over array? [
+    over { [ array? ] [ empty? not ] } 1&& [
         over first dup malsymbol? [ name>> ] when {
             { "def!" [ [ rest first2 ] dip eval-def! f ] }
             { "let*" [ [ first2 ] dip eval-let* ] }
index 280307a..41a66dd 100755 (executable)
@@ -87,7 +87,7 @@ M: callable apply call( x -- y ) f ;
 : READ ( str -- maltype ) read-str ;
 
 : EVAL ( maltype env -- maltype )
-    over array? [
+    over { [ array? ] [ empty? not ] } 1&& [
         [ macro-expand ] keep over array? [
             over first dup malsymbol? [ name>> ] when {
                 { "def!" [ [ rest first2 ] dip eval-def! f ] }
index af2eb02..93416f4 100755 (executable)
@@ -94,7 +94,7 @@ M: callable apply call( x -- y ) f ;
 : READ ( str -- maltype ) read-str ;
 
 : EVAL ( maltype env -- maltype )
-    over array? [
+    over { [ array? ] [ empty? not ] } 1&& [
         [ macro-expand ] keep over array? [
             over first dup malsymbol? [ name>> ] when {
                 { "def!" [ [ rest first2 ] dip eval-def! f ] }
index 97ba797..75909e9 100755 (executable)
@@ -94,7 +94,7 @@ M: callable apply call( x -- y ) f ;
 : READ ( str -- maltype ) read-str ;
 
 : EVAL ( maltype env -- maltype )
-    over array? [
+    over { [ array? ] [ empty? not ] } 1&& [
         [ macro-expand ] keep over array? [
             over first dup malsymbol? [ name>> ] when {
                 { "def!" [ [ rest first2 ] dip eval-def! f ] }