]> gitweb.factorcode.org Git - factor.git/commitdiff
classes.maybe: Change the type of maybe's class slot. As a result, maybe: maybe:...
authorDoug Coleman <doug.coleman@gmail.com>
Wed, 23 Nov 2011 09:43:02 +0000 (01:43 -0800)
committerDoug Coleman <doug.coleman@gmail.com>
Wed, 23 Nov 2011 09:43:02 +0000 (01:43 -0800)
basis/prettyprint/prettyprint-tests.factor
core/classes/maybe/maybe-tests.factor
core/classes/maybe/maybe.factor

index b3d78268d28f9ca54482f4f8a06f06d5f3c7ae0f..0a1adae8a0729f30fe5e43122c1969b8bec2b725 100644 (file)
@@ -449,3 +449,9 @@ TUPLE: fo { a intersection{ fixnum integer } initial: 0 } ;
 ] [
     [ maybe: union{ float integer } . ] with-string-writer
 ] unit-test
+
+[
+"""maybe: maybe: integer\n"""
+] [
+    [ maybe: maybe: integer . ] with-string-writer
+] unit-test
index b11b5f14f54ea295d26b05f07441021db0058aa1..5f536e906c780aebef86ae609a9d833a0cd80a21 100644 (file)
@@ -28,7 +28,9 @@ PREDICATE: natural < maybe: integer
 [ f ] [ 0 natural? ] unit-test
 [ t ] [ 1 natural? ] unit-test
 
-[ "USE: math maybe: maybe: integer" eval( -- obj ) ] [ error>> bad-slot-value? ] must-fail-with
+[ t ] [ f maybe: maybe: integer instance? ] unit-test
+[ t ] [ 3 maybe: maybe: integer instance? ] unit-test
+[ f ] [ 3.03 maybe: maybe: integer instance? ] unit-test
 
 INTERSECTION: only-f maybe: integer POSTPONE: f ;
 
index f0b05f88ee64ffe50a3350e83be0a30e8bc225ba..56c57343e1bb66d67704d7aa5e0a95453db391db 100644 (file)
@@ -5,7 +5,12 @@ classes.algebra.private classes.private classes.union.private
 effects kernel words ;
 IN: classes.maybe
 
-TUPLE: maybe { class classoid initial: object read-only } ;
+! The class slot has to be a union of a word and a classoid
+! for TUPLE: foo { a maybe: foo } ; and maybe: union{ integer float } to work.
+! In the first case, foo is not yet a tuple-class when maybe: is reached,
+! thus it's not a classoid yet. union{ is a classoid, so the second case works.
+! words are not generally classoids, so classoid alone is insufficient.
+TUPLE: maybe { class union{ word classoid } initial: object read-only } ;
 
 C: <maybe> maybe