]> gitweb.factorcode.org Git - factor.git/commitdiff
sequences: integer slots in slice, don't store reason in slice-error.
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 16 Jul 2015 22:35:03 +0000 (15:35 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 16 Jul 2015 22:35:03 +0000 (15:35 -0700)
basis/debugger/debugger.factor
core/sequences/sequences.factor

index 3cac57326a3749fd6b9ae4692882243964a3f305..bac63016eeaa9844e237c7ebba69361e34d5d042 100755 (executable)
@@ -235,7 +235,12 @@ M: no-case summary
     drop "Fall-through in case" ;
 
 M: slice-error summary
-    drop "Cannot create slice" ;
+    "Cannot create slice" swap {
+        { [ dup from>> 0 < ] [ ": from < 0" ] }
+        { [ dup [ to>> ] [ seq>> length ] bi > ] [ ": to > length" ] }
+        { [ dup [ from>> ] [ to>> ] bi > ] [ ": from > to" ] }
+        [ f ]
+    } cond nip append ;
 
 M: bounds-error summary drop "Sequence index out of bounds" ;
 
index d16f3b9557db3b8dc385c8c0fb95ff8cf9903088..018efc85d1a2ee38664dc80575152eb7d273f301 100644 (file)
@@ -214,24 +214,19 @@ INSTANCE: reversed virtual-sequence
 
 ! A slice of another sequence.
 TUPLE: slice
-{ from read-only }
-{ to read-only }
-{ seq read-only } ;
+    { from integer read-only }
+    { to integer read-only }
+    { seq read-only } ;
 
 : collapse-slice ( m n slice -- m' n' seq )
     [ from>> ] [ seq>> ] bi [ [ + ] curry bi@ ] dip ; inline
 
-ERROR: slice-error from to seq reason ;
-
-: check-slice-error ( from to seq ? string -- from to seq )
-    [ slice-error ] curry when ; inline
+ERROR: slice-error from to seq ;
 
 : check-slice ( from to seq -- from to seq )
-    3dup
-    [ 2drop 0 < "start < 0" check-slice-error ]
-    [ [ drop ] 2dip length > "end > sequence" check-slice-error ]
-    [ drop > "start > end" check-slice-error ]
-    3tri ; inline
+    pick 0 < [ slice-error ] when
+    2dup length > [ slice-error ] when
+    2over > [ slice-error ] when ; inline
 
 <PRIVATE