From fac17c10ba5c3d938f4b94c4b71fece455cffe78 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Tue, 22 Nov 2011 02:44:58 -0800 Subject: [PATCH] classes.maybe: move maybe definition from classes.union to classes.maybe --- basis/compiler/tests/redefine26.factor | 2 +- .../tree/propagation/simple/simple.factor | 2 +- basis/prettyprint/backend/backend.factor | 2 +- basis/prettyprint/prettyprint-tests.factor | 2 +- basis/typed/typed.factor | 2 +- core/classes/maybe/authors.txt | 1 + core/classes/maybe/maybe.factor | 32 +++++++++++++++++++ core/classes/union/union.factor | 31 +++--------------- core/generic/generic.factor | 5 +-- core/slots/slots.factor | 2 +- core/syntax/syntax.factor | 2 +- 11 files changed, 45 insertions(+), 38 deletions(-) create mode 100644 core/classes/maybe/authors.txt create mode 100644 core/classes/maybe/maybe.factor diff --git a/basis/compiler/tests/redefine26.factor b/basis/compiler/tests/redefine26.factor index 9aa94b3a9c..7b2d89aa9d 100644 --- a/basis/compiler/tests/redefine26.factor +++ b/basis/compiler/tests/redefine26.factor @@ -1,4 +1,4 @@ -USING: accessors classes.tuple classes.union compiler.units +USING: accessors classes.tuple classes.maybe compiler.units kernel math slots tools.test ; IN: compiler.tests.redefine26 diff --git a/basis/compiler/tree/propagation/simple/simple.factor b/basis/compiler/tree/propagation/simple/simple.factor index d60cf50495..e1bcc07ef4 100644 --- a/basis/compiler/tree/propagation/simple/simple.factor +++ b/basis/compiler/tree/propagation/simple/simple.factor @@ -5,7 +5,7 @@ words namespaces classes.algebra combinators combinators.short-circuit classes classes.tuple classes.tuple.private continuations arrays alien.c-types math math.private slots generic definitions stack-checker.dependencies -classes.union classes.algebra.private +classes.maybe classes.algebra.private compiler.tree compiler.tree.propagation.info compiler.tree.propagation.nodes diff --git a/basis/prettyprint/backend/backend.factor b/basis/prettyprint/backend/backend.factor index 797f04774a..e942bfdd2f 100644 --- a/basis/prettyprint/backend/backend.factor +++ b/basis/prettyprint/backend/backend.factor @@ -7,7 +7,7 @@ io.pathnames io.styles kernel make math math.order math.parser namespaces prettyprint.config prettyprint.custom prettyprint.sections prettyprint.stylesheet quotations sbufs sequences strings vectors words words.symbol hash-sets -classes.union ; +classes.maybe ; FROM: sets => members ; IN: prettyprint.backend diff --git a/basis/prettyprint/prettyprint-tests.factor b/basis/prettyprint/prettyprint-tests.factor index 7353cccb43..f9d532f778 100644 --- a/basis/prettyprint/prettyprint-tests.factor +++ b/basis/prettyprint/prettyprint-tests.factor @@ -4,7 +4,7 @@ prettyprint.sections sequences tools.test vectors words effects splitting generic.standard prettyprint.private continuations generic compiler.units tools.continuations tools.continuations.private eval accessors make vocabs.parser see -listener classes.union ; +listener classes.maybe ; IN: prettyprint.tests [ "4" ] [ 4 unparse ] unit-test diff --git a/basis/typed/typed.factor b/basis/typed/typed.factor index 2d76d25b13..fc1eee608c 100644 --- a/basis/typed/typed.factor +++ b/basis/typed/typed.factor @@ -4,7 +4,7 @@ combinators.short-circuit definitions effects fry hints math kernel kernel.private namespaces parser quotations sequences slots words locals effects.parser locals.parser macros stack-checker.dependencies -classes.union ; +classes.maybe ; FROM: classes.tuple.private => tuple-layout ; IN: typed diff --git a/core/classes/maybe/authors.txt b/core/classes/maybe/authors.txt new file mode 100644 index 0000000000..7c1b2f2279 --- /dev/null +++ b/core/classes/maybe/authors.txt @@ -0,0 +1 @@ +Doug Coleman diff --git a/core/classes/maybe/maybe.factor b/core/classes/maybe/maybe.factor new file mode 100644 index 0000000000..0fa63fb251 --- /dev/null +++ b/core/classes/maybe/maybe.factor @@ -0,0 +1,32 @@ +! Copyright (C) 2011 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors classes classes.algebra +classes.algebra.private classes.private effects generic +kernel sequences words classes.union classes.union.private ; +IN: classes.maybe + +TUPLE: maybe { class word initial: object read-only } ; + +C: maybe + +M: maybe instance? + over [ class>> instance? ] [ 2drop t ] if ; + +M: maybe normalize-class + class>> \ f class-or ; + +M: maybe classoid? drop t ; + +M: maybe rank-class drop 6 ; + +M: maybe (flatten-class) + class>> (flatten-class) ; + +M: maybe effect>type ; + +M: maybe method-word-name + [ class>> name>> ] [ name>> ] bi* "=>" glue ; + +M: maybe union-of-builtins? + class>> union-of-builtins? ; + diff --git a/core/classes/union/union.factor b/core/classes/union/union.factor index fc70ae06f7..385719b552 100644 --- a/core/classes/union/union.factor +++ b/core/classes/union/union.factor @@ -1,33 +1,14 @@ ! Copyright (C) 2004, 2011 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: words sequences kernel assocs combinators classes -classes.private classes.algebra classes.algebra.private -classes.builtin kernel.private math.private namespaces arrays -math quotations definitions accessors parser effects ; +USING: accessors assocs classes classes.algebra +classes.algebra.private classes.builtin +classes.private combinators definitions kernel kernel.private +math math.private quotations sequences words vocabs ; IN: classes.union PREDICATE: union-class < class "metaclass" word-prop union-class eq? ; -TUPLE: maybe { class word initial: object read-only } ; - -C: maybe - -M: maybe instance? - over [ class>> instance? ] [ 2drop t ] if ; - -M: maybe normalize-class - class>> \ f class-or ; - -M: maybe classoid? drop t ; - -M: maybe rank-class drop 6 ; - -M: maybe (flatten-class) - class>> (flatten-class) ; - -M: maybe effect>type ; - > union-of-builtins? ; - M: class union-of-builtins? drop f ; @@ -96,4 +74,3 @@ M: union-class normalize-class M: union-class (flatten-class) members (flatten-class) ; - diff --git a/core/generic/generic.factor b/core/generic/generic.factor index 6bbba70882..d3c13f1228 100644 --- a/core/generic/generic.factor +++ b/core/generic/generic.factor @@ -3,7 +3,7 @@ USING: accessors words kernel sequences namespaces make assocs hashtables definitions kernel.private classes classes.private classes.algebra quotations arrays vocabs effects combinators -sets classes.union ; +sets ; FROM: namespaces => set ; IN: generic @@ -109,9 +109,6 @@ GENERIC: update-generic ( class generic -- ) GENERIC# method-word-name 1 ( class generic -- string ) -M: maybe method-word-name - [ class>> name>> ] [ name>> ] bi* "=>" glue ; - M: class method-word-name ( class generic -- string ) [ name>> ] bi@ "=>" glue ; diff --git a/core/slots/slots.factor b/core/slots/slots.factor index adb0db5582..5bb1630eb8 100644 --- a/core/slots/slots.factor +++ b/core/slots/slots.factor @@ -4,7 +4,7 @@ USING: arrays byte-arrays kernel kernel.private math namespaces make sequences strings effects generic generic.standard classes classes.algebra slots.private combinators accessors words sequences.private assocs alien quotations hashtables -classes.union ; +classes.maybe ; IN: slots TUPLE: slot-spec name offset class initial read-only ; diff --git a/core/syntax/syntax.factor b/core/syntax/syntax.factor index 5efd0d8014..b4c2c5b065 100644 --- a/core/syntax/syntax.factor +++ b/core/syntax/syntax.factor @@ -7,7 +7,7 @@ words.alias quotations io assocs splitting classes.tuple generic.standard generic.hook generic.math generic.parser classes io.pathnames vocabs vocabs.parser classes.parser classes.union classes.intersection classes.mixin classes.predicate -classes.singleton classes.tuple.parser compiler.units +classes.singleton classes.tuple.parser compiler.units classes.maybe combinators effects.parser slots hash-sets source-files ; IN: bootstrap.syntax