]> gitweb.factorcode.org Git - factor.git/commitdiff
Rename tuples vocab to classes.tuple for consistency
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sat, 29 Mar 2008 08:34:48 +0000 (03:34 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sat, 29 Mar 2008 08:34:48 +0000 (03:34 -0500)
80 files changed:
core/alien/alien.factor
core/bootstrap/compiler/compiler.factor
core/bootstrap/image/image.factor
core/bootstrap/layouts/layouts.factor
core/bootstrap/primitives.factor
core/classes/tuple/authors.txt [new file with mode: 0644]
core/classes/tuple/summary.txt [new file with mode: 0644]
core/classes/tuple/tuple-docs.factor [new file with mode: 0755]
core/classes/tuple/tuple-tests.factor [new file with mode: 0755]
core/classes/tuple/tuple.factor [new file with mode: 0755]
core/cpu/arm/intrinsics/intrinsics.factor
core/cpu/ppc/intrinsics/intrinsics.factor
core/cpu/x86/intrinsics/intrinsics.factor
core/debugger/debugger.factor
core/inference/inference-tests.factor
core/inference/known-words/known-words.factor
core/inference/transforms/transforms.factor
core/kernel/kernel.factor
core/listener/listener.factor
core/mirrors/mirrors.factor
core/optimizer/known-words/known-words.factor
core/optimizer/optimizer-tests.factor
core/parser/parser-tests.factor
core/prettyprint/backend/backend.factor
core/prettyprint/prettyprint.factor
core/refs/refs.factor
core/slots/slots-docs.factor
core/syntax/syntax-docs.factor
core/syntax/syntax.factor
core/tuples/authors.txt [deleted file]
core/tuples/summary.txt [deleted file]
core/tuples/tuples-docs.factor [deleted file]
core/tuples/tuples-tests.factor [deleted file]
core/tuples/tuples.factor [deleted file]
core/vocabs/loader/loader-tests.factor
core/words/words-tests.factor
extra/bake/bake.factor
extra/calendar/calendar.factor
extra/classes/tuple/lib/authors.txt [new file with mode: 0644]
extra/classes/tuple/lib/lib-docs.factor [new file with mode: 0644]
extra/classes/tuple/lib/lib-tests.factor [new file with mode: 0644]
extra/classes/tuple/lib/lib.factor [new file with mode: 0755]
extra/db/db.factor
extra/db/sql/sql.factor
extra/db/sqlite/sqlite.factor
extra/db/tuples/tuples.factor
extra/db/types/types.factor
extra/editors/editors.factor
extra/help/help.factor
extra/http/server/components/components.factor
extra/inverse/inverse.factor
extra/io/encodings/8-bit/8-bit.factor
extra/io/nonblocking/nonblocking-docs.factor
extra/io/windows/nt/backend/backend.factor
extra/io/windows/nt/sockets/sockets.factor
extra/json/writer/writer.factor
extra/match/match.factor
extra/models/models-docs.factor
extra/serialize/serialize.factor
extra/tools/disassembler/disassembler-tests.factor
extra/tuple-arrays/tuple-arrays.factor
extra/tuples/lib/authors.txt [deleted file]
extra/tuples/lib/lib-docs.factor [deleted file]
extra/tuples/lib/lib-tests.factor [deleted file]
extra/tuples/lib/lib.factor [deleted file]
extra/ui/gadgets/buttons/buttons.factor
extra/ui/gadgets/canvas/canvas.factor
extra/ui/gadgets/frames/frames-docs.factor
extra/ui/gadgets/gadgets-docs.factor
extra/ui/gadgets/labelled/labelled.factor
extra/ui/gadgets/lists/lists.factor
extra/ui/gadgets/packs/packs-docs.factor
extra/ui/gadgets/panes/panes.factor
extra/ui/gadgets/presentations/presentations-tests.factor
extra/ui/gadgets/scrollers/scrollers.factor
extra/ui/gadgets/tracks/tracks-docs.factor
extra/ui/gestures/gestures.factor
extra/ui/tools/interactor/interactor.factor
extra/ui/tools/search/search.factor
extra/ui/x11/x11.factor

index 777bf523a5c27f212904ed4cc70ff44686edaffb..d0adec1fcfcc9b8b93fffb3ca1155a681057a14c 100755 (executable)
@@ -1,8 +1,7 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: assocs kernel math namespaces sequences system
-kernel.private tuples bit-arrays byte-arrays float-arrays 
-arrays ;
+kernel.private bit-arrays byte-arrays float-arrays arrays ;
 IN: alien
 
 ! Some predicate classes used by the compiler for optimization
index af2cc79579e834e06207ff1e13e577de18e96fac..7d4db3c473a69612453f36ca38cf7c81946f6feb 100755 (executable)
@@ -2,8 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: compiler cpu.architecture vocabs.loader system sequences
 namespaces parser kernel kernel.private classes classes.private
-arrays hashtables vectors tuples sbufs inference.dataflow
-hashtables.private sequences.private math tuples.private
+arrays hashtables vectors classes.tuple sbufs inference.dataflow
+hashtables.private sequences.private math classes.tuple.private
 growable namespaces.private assocs words generator command-line
 vocabs io prettyprint libc compiler.units ;
 IN: bootstrap.compiler
index 7fd43612464b8e8b5b11475d838de1a2848d2da2..deb54fdeeb6d230ab19374dac660d4a9c4676f87 100755 (executable)
@@ -4,10 +4,11 @@ USING: alien arrays bit-arrays byte-arrays generic assocs
 hashtables assocs hashtables.private io kernel kernel.private
 math namespaces parser prettyprint sequences sequences.private
 strings sbufs vectors words quotations assocs system layouts
-splitting growable classes tuples tuples.private words.private
-io.binary io.files vocabs vocabs.loader source-files
-definitions debugger float-arrays quotations.private
-sequences.private combinators io.encodings.binary ;
+splitting growable classes classes.tuple classes.tuple.private
+words.private io.binary io.files vocabs vocabs.loader
+source-files definitions debugger float-arrays
+quotations.private sequences.private combinators
+io.encodings.binary ;
 IN: bootstrap.image
 
 : my-arch ( -- arch )
index 316fa3cd723a7b1f6c4264b84ea724da7f84af4c..846cce153bb62ad2d391d0233b74c949b3a75484 100755 (executable)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: namespaces math words kernel alien byte-arrays
 hashtables vectors strings sbufs arrays bit-arrays
-float-arrays quotations assocs layouts tuples tuples.private ;
+float-arrays quotations assocs layouts classes.tuple.private ;
 
 BIN: 111 tag-mask set
 8 num-tags set
index 50dea27e7bcad983139867735cbf7c14a486f063..2e1a7f9f57a797ad3469a1be054ab25fc2cefddc 100755 (executable)
@@ -2,10 +2,10 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien arrays byte-arrays generic hashtables
 hashtables.private io kernel math namespaces parser sequences
-strings vectors words quotations assocs layouts classes tuples
-tuples.private kernel.private vocabs vocabs.loader source-files
-definitions slots.deprecated classes.union compiler.units
-bootstrap.image.private io.files ;
+strings vectors words quotations assocs layouts classes
+classes.tuple classes.tuple.private kernel.private vocabs
+vocabs.loader source-files definitions slots.deprecated
+classes.union compiler.units bootstrap.image.private io.files ;
 IN: bootstrap.primitives
 
 "Creating primitives and basic runtime structures..." print flush
@@ -60,6 +60,8 @@ num-types get f <array> builtins set
     "byte-arrays"
     "byte-vectors"
     "classes.private"
+    "classes.tuple"
+    "classes.tuple.private"
     "compiler.units"
     "continuations.private"
     "float-arrays"
@@ -91,8 +93,6 @@ num-types get f <array> builtins set
     "system.private"
     "threads.private"
     "tools.profiler.private"
-    "tuples"
-    "tuples.private"
     "words"
     "words.private"
     "vectors"
@@ -291,35 +291,35 @@ define-builtin
 
 "callstack" "kernel" create { } define-builtin
 
-"tuple-layout" "tuples.private" create {
+"tuple-layout" "classes.tuple.private" create {
     {
         { "fixnum" "math" }
         "hashcode"
-        { "layout-hashcode" "tuples.private" }
+        { "layout-hashcode" "classes.tuple.private" }
         f
     }
     {
         { "word" "words" }
         "class"
-        { "layout-class" "tuples.private" }
+        { "layout-class" "classes.tuple.private" }
         f
     }
     {
         { "fixnum" "math" }
         "size"
-        { "layout-size" "tuples.private" }
+        { "layout-size" "classes.tuple.private" }
         f
     }
     {
         { "array" "arrays" }
         "superclasses"
-        { "layout-superclasses" "tuples.private" }
+        { "layout-superclasses" "classes.tuple.private" }
         f
     }
     {
         { "fixnum" "math" }
         "echelon"
-        { "layout-echelon" "tuples.private" }
+        { "layout-echelon" "classes.tuple.private" }
         f
     }
 } define-builtin
@@ -694,13 +694,13 @@ dup tuple-layout [ <tuple-boa> ] curry define
     { "<string>" "strings" }
     { "array>quotation" "quotations.private" }
     { "quotation-xt" "quotations" }
-    { "<tuple>" "tuples.private" }
-    { "<tuple-layout>" "tuples.private" }
+    { "<tuple>" "classes.tuple.private" }
+    { "<tuple-layout>" "classes.tuple.private" }
     { "profiling" "tools.profiler.private" }
     { "become" "kernel.private" }
     { "(sleep)" "threads.private" }
     { "<float-array>" "float-arrays" }
-    { "<tuple-boa>" "tuples.private" }
+    { "<tuple-boa>" "classes.tuple.private" }
     { "class-hash" "kernel.private" }
     { "callstack>array" "kernel" }
     { "innermost-frame-quot" "kernel.private" }
diff --git a/core/classes/tuple/authors.txt b/core/classes/tuple/authors.txt
new file mode 100644 (file)
index 0000000..1901f27
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
diff --git a/core/classes/tuple/summary.txt b/core/classes/tuple/summary.txt
new file mode 100644 (file)
index 0000000..4dbb643
--- /dev/null
@@ -0,0 +1 @@
+Object system implementation
diff --git a/core/classes/tuple/tuple-docs.factor b/core/classes/tuple/tuple-docs.factor
new file mode 100755 (executable)
index 0000000..a747008
--- /dev/null
@@ -0,0 +1,290 @@
+USING: generic help.markup help.syntax kernel
+classes.tuple.private classes slots quotations words arrays
+generic.standard sequences definitions compiler.units ;
+IN: classes.tuple
+
+ARTICLE: "tuple-constructors" "Constructors"
+"Tuples are created by calling one of two words:"
+{ $subsection construct-empty }
+{ $subsection construct-boa }
+"By convention, construction logic is encapsulated in a word named after the tuple class surrounded in angle brackets; for example, the constructor word for a " { $snippet "point" } " class might be named " { $snippet "<point>" } "."
+$nl
+"A shortcut for defining BOA constructors:"
+{ $subsection POSTPONE: C: }
+"Examples of constructors:"
+{ $code
+    "TUPLE: color red green blue alpha ;"
+    ""
+    "C: <rgba> rgba"
+    ": <rgba> color construct-boa ; ! identical to above"
+    ""
+    ": <rgb> f <rgba> ;"
+    ""
+    ": <color> construct-empty ;"
+    ": <color> f f f f <rgba> ; ! identical to above"
+} ;
+
+ARTICLE: "tuple-delegation" "Tuple delegation"
+"If a generic word having the " { $link standard-combination } " method combination is called on a tuple for which it does not have an applicable method, the method call is forwarded to the tuple's " { $emphasis "delegate" } ". If no delegate is set, a " { $link no-method } " error is thrown."
+{ $subsection delegate }
+{ $subsection set-delegate }
+"A tuple's delegate should either be another tuple, or " { $link f } ", indicating no delegate is set. Delegation from a tuple to an object of some other type is not fully supported and should be used with caution."
+$nl
+"Factor uses delegation in place of implementation inheritance, but it is not a direct substitute; in particular, the semantics differ in that a delegated method call receives the delegate on the stack, not the original object."
+$nl
+"A pair of words examine delegation chains:"
+{ $subsection delegates }
+{ $subsection is? }
+"An example:"
+{ $example
+    "TUPLE: ellipse center radius ;"
+    "TUPLE: colored color ;"
+    "{ 0 0 } 10 <ellipse> \"my-ellipse\" set"
+    "{ 1 0 0 } <colored> \"my-shape\" set"
+    "\"my-ellipse\" get \"my-shape\" get set-delegate"
+    "\"my-shape\" get dup color>> swap center>> .s"
+    "{ 0 0 }\n{ 1 0 0 }"
+} ;
+
+ARTICLE: "tuple-introspection" "Tuple introspection"
+"In addition to the slot reader and writer words which " { $link POSTPONE: TUPLE: } " defines for every tuple class, it is possible to construct and take apart entire tuples in a generic way."
+{ $subsection >tuple }
+{ $subsection tuple>array }
+{ $subsection tuple-slots }
+"Tuple classes can also be defined at run time:"
+{ $subsection define-tuple-class }
+{ $see-also "slots" "mirrors" } ;
+
+ARTICLE: "tuple-examples" "Tuple examples"
+"An example:"
+{ $code "TUPLE: employee name salary position ;" }
+"This defines a class word named " { $snippet "employee" } ", a predicate " { $snippet "employee?" } ", and the following slot accessors:"
+{ $table
+    { "Reader" "Writer" "Setter" "Changer" }
+    { { $snippet "name>>" }    { $snippet "(>>name)" }    { $snippet ">>name" }    { $snippet "change-name" }    }
+    { { $snippet "salary>>" } { $snippet "(>>salary)" } { $snippet ">>salary" } { $snippet "change-salary" } }
+    { { $snippet "position>>" }   { $snippet "(>>position)" }   { $snippet ">>position" }   { $snippet "change-position" }   }
+}
+"We can define a constructor which makes an empty employee:"
+{ $code ": <employee> ( -- employee )"
+    "    employee construct-empty ;" }
+"Or we may wish the default constructor to always give employees a starting salary:"
+{ $code
+    ": <employee> ( -- employee )"
+    "    employee construct-empty"
+    "        40000 >>salary ;"
+}
+"We can define more refined constructors:"
+{ $code
+    ": <manager> ( -- manager )"
+    "    <employee> \"project manager\" >>position ;" }
+"An alternative strategy is to define the most general BOA constructor first:"
+{ $code
+    ": <employee> ( name position -- person )"
+    "    40000 employee construct-boa ;"
+}
+"Now we can define more specific constructors:"
+{ $code
+    ": <manager> ( name -- person )"
+    "    \"manager\" <person> ;" }
+"An example using reader words:"
+{ $code
+    "TUPLE: check to amount number ;"
+    ""
+    "SYMBOL: checks"
+    ""
+    ": <check> ( to amount -- check )"
+    "    checks counter check construct-boa ;"
+    ""
+    ": biweekly-paycheck ( employee -- check )"
+    "    dup name>> swap salary>> 26 / <check> ;"
+}
+"An example of using a changer:"
+{ $code
+    ": positions"
+    "    {"
+    "        \"junior programmer\""
+    "        \"senior programmer\""
+    "        \"project manager\""
+    "        \"department manager\""
+    "        \"executive\""
+    "        \"CTO\""
+    "        \"CEO\""
+    "        \"enterprise Java world dictator\""
+    "    } ;"
+    ""
+    ": next-position ( role -- newrole )"
+    "    positions [ index 1+ ] keep nth ;"
+    ""
+    ": promote ( person -- person )"
+    "    [ 1.2 * ] change-salary"
+    "    [ next-position ] change-position ;"
+} ;
+
+ARTICLE: "tuples" "Tuples"
+"Tuples are user-defined classes composed of named slots."
+{ $subsection "tuple-examples" }
+"A parsing word defines tuple classes:"
+{ $subsection POSTPONE: TUPLE: }
+"For each tuple class, several words are defined. First, there is the class word, a class predicate, and accessor words for each slot."
+$nl
+"The class word is used for defining methods on the tuple class; it has the same name as the tuple class. The predicate is named " { $snippet { $emphasis "name" } "?" } ". Tuple slots are accessed via accessor words:"
+{ $subsection "accessors" }
+"Initially, no specific words are defined for constructing new instances of the tuple. Constructors must be defined explicitly:"
+{ $subsection "tuple-constructors" }
+"Further topics:"
+{ $subsection "tuple-delegation" }
+{ $subsection "tuple-introspection" }
+"Tuple literal syntax is documented in " { $link "syntax-tuples" } "." ;
+
+ABOUT: "tuples"
+
+HELP: delegate
+{ $values { "obj" object } { "delegate" object } }
+{ $description "Returns an object's delegate, or " { $link f } " if no delegate is set." }
+{ $notes "A direct consequence of this behavior is that an object may not have a delegate of " { $link f } "." } ;
+
+HELP: set-delegate
+{ $values { "delegate" object } { "tuple" tuple } }
+{ $description "Sets a tuple's delegate. Method calls not handled by the tuple's class will now be passed on to the delegate." } ;
+
+HELP: tuple=
+{ $values { "tuple1" tuple } { "tuple2" tuple } { "?" "a boolean" } }
+{ $description "Low-level tuple equality test. User code should use " { $link = } " instead." }
+{ $warning "This word is in the " { $vocab-link "classes.tuple.private" } " vocabulary because it does not do any type checking. Passing values which are not tuples can result in memory corruption." } ;
+
+HELP: permutation
+{ $values { "seq1" sequence } { "seq2" sequence } { "permutation" "a sequence whose elements are integers or " { $link f } } }
+{ $description "Outputs a permutation for taking " { $snippet "seq1" } " to " { $snippet "seq2" } "." } ;
+
+HELP: reshape-tuple
+{ $values { "oldtuple" tuple } { "permutation" "a sequence whose elements are integers or " { $link f } } { "newtuple" tuple } }
+{ $description "Permutes the slots of a tuple. If a tuple class is redefined at runtime, this word is called on every instance to change its shape to conform to the new layout." } ;
+
+HELP: reshape-tuples
+{ $values { "class" tuple-class } { "newslots" "a sequence of strings" } }
+{ $description "Changes the shape of every instance of " { $snippet "class" } " for a new slot layout." } ;
+
+HELP: removed-slots
+{ $values { "class" tuple-class } { "newslots" "a sequence of strings" } { "seq" "a sequence of strings" } }
+{ $description "Outputs the sequence of existing tuple slot names not in " { $snippet "newslots" } "." } ;
+
+HELP: forget-slots
+{ $values { "class" tuple-class } { "newslots" "a sequence of strings" } }
+{ $description "Forgets accessor words for existing tuple slots which are not in " { $snippet "newslots" } "." } ;
+
+HELP: tuple
+{ $class-description "The class of tuples. This class is further partitioned into disjoint subclasses; each tuple shape defined by " { $link POSTPONE: TUPLE: } " is a new class."
+$nl
+"Tuple classes have additional word properties:"
+{ $list
+    { { $snippet "\"constructor\"" } " - a word for creating instances of this tuple class" }
+    { { $snippet "\"predicate\"" } " - a quotation which tests if the top of the stack is an instance of this tuple class" }
+    { { $snippet "\"slots\"" } " - a sequence of " { $link slot-spec } " instances" }
+    { { $snippet "\"slot-names\"" } " - a sequence of strings naming the tuple's slots" }
+    { { $snippet "\"tuple-size\"" } " - the number of slots" }
+} } ;
+
+HELP: define-tuple-predicate
+{ $values { "class" tuple-class } }
+{ $description "Defines a predicate word that tests if the top of the stack is an instance of " { $snippet "class" } ". This will only work if " { $snippet "class" } " is a tuple class." }
+$low-level-note ;
+
+HELP: redefine-tuple-class
+{ $values { "class" class } { "superclass" class } { "slots" "a sequence of strings" } }
+{ $description "If the new slot layout differs from the existing one, updates all existing instances of this tuple class, and forgets any slot accessor words which are no longer needed."
+$nl
+"If the class is not a tuple class word, this word does nothing." }
+$low-level-note ;
+
+HELP: tuple-slots
+{ $values { "tuple" tuple } { "seq" sequence } }
+{ $description "Pushes a sequence of tuple slot values, not including the tuple class word and delegate." } ;
+
+{ tuple-slots tuple>array } related-words
+
+HELP: define-tuple-slots
+{ $values { "class" tuple-class } { "slots" "a sequence of strings" } }
+{ $description "Defines slot accessor and mutator words for the tuple." }
+$low-level-note ;
+
+HELP: check-tuple
+{ $values { "class" class } }
+{ $description "Throws a " { $link check-tuple } " error if " { $snippet "word" } " is not a tuple class word." }
+{ $error-description "Thrown if " { $link POSTPONE: C: } " is called with a word which does not name a tuple class." } ;
+
+HELP: define-tuple-class
+{ $values { "class" word } { "superclass" class } { "slots" "a sequence of strings" } }
+{ $description "Defines a tuple class inheriting from " { $snippet "superclass" } " with slots named by " { $snippet "slots" } ". This is the run time equivalent of " { $link POSTPONE: TUPLE: } "." }
+{ $notes "This word must be called from inside " { $link with-compilation-unit } "." }
+{ $side-effects "class" } ;
+
+{ tuple-class define-tuple-class POSTPONE: TUPLE: } related-words
+
+HELP: delegates
+{ $values { "obj" object } { "seq" sequence } }
+{ $description "Outputs the delegation chain of an object. The first element of " { $snippet "seq" } " is " { $snippet "obj" } " itself. If " { $snippet "obj" } " is " { $link f } ", an empty sequence is output." } ;
+
+HELP: is?
+{ $values { "obj" object } { "quot" "a quotation with stack effect " { $snippet "( obj -- ? )" } } { "?" "a boolean" } }
+{ $description "Tests if the object or one of its delegates satisfies the predicate quotation."
+$nl
+"Class membership test predicates only test if an object is a direct instance of that class. Sometimes, you need to check delegates, since this gives a clearer picture of what operations the object supports." } ;
+
+HELP: >tuple
+{ $values { "seq" sequence } { "tuple" tuple } }
+{ $description "Creates a tuple with slot values taken from a sequence. The first element of the sequence must be a tuple class word, the second a delegate, and the remainder the declared slots."
+$nl
+"If the sequence has too many elements, they are ignored, and if it has too few, the remaining slots in the tuple are set to " { $link f } "." }
+{ $errors "Throws an error if the first element of the sequence is not a tuple class word." } ;
+
+HELP: tuple>array ( tuple -- array )
+{ $values { "tuple" tuple } { "array" array } }
+{ $description "Outputs an array having the tuple's slots as elements. The first element is the tuple class word and the second is the delegate; the remainder are declared slots." } ;
+
+HELP: <tuple> ( layout -- tuple )
+{ $values { "layout" tuple-layout } { "tuple" tuple } }
+{ $description "Low-level tuple constructor. User code should never call this directly, and instead use " { $link construct-empty } "." } ;
+
+HELP: <tuple-boa> ( ... layout -- tuple )
+{ $values { "..." "values" } { "layout" tuple-layout } { "tuple" tuple } }
+{ $description "Low-level tuple constructor. User code should never call this directly, and instead use " { $link construct-boa } "." } ;
+
+HELP: construct-empty
+{ $values { "class" tuple-class } { "tuple" tuple } }
+{ $description "Creates a new instance of " { $snippet "class" } " with all slots initially set to " { $link f } "." }
+{ $examples
+    { $example
+        "USING: kernel prettyprint ;"
+        "TUPLE: employee number name department ;"
+        "employee construct-empty ."
+        "T{ employee f f f f }"
+    }
+} ;
+
+HELP: construct
+{ $values { "..." "slot values" } { "slots" "a sequence of setter words" } { "class" tuple-class } { "tuple" tuple } }
+{ $description "Creates a new instance of " { $snippet "class" } ", storing consecutive stack values into the slots of the new tuple using setter words in " { $snippet "slots" } ". The top-most stack element is stored in the right-most slot." }
+{ $examples
+    "We can define a class:"
+    { $code "TUPLE: color red green blue alpha ;" }
+    "Together with two constructors:"
+    { $code
+        ": <rgb> ( r g b -- color )"
+        "    { set-color-red set-color-green set-color-blue }"
+        "    color construct ;"
+        ""
+        ": <rgba> ( r g b a -- color )"
+        "    { set-color-red set-color-green set-color-blue set-color-alpha }"
+        "    color construct ;"
+    }
+    "The last definition is actually equivalent to the following:"
+    { $code ": <rgba> ( r g b a -- color ) rgba construct-boa ;" }
+    "Which can be abbreviated further:"
+    { $code "C: <rgba> color" }
+} ;
+
+HELP: construct-boa
+{ $values { "..." "slot values" } { "class" tuple-class } { "tuple" tuple } }
+{ $description "Creates a new instance of " { $snippet "class" } " and fill in the slots from the stack, with the top-most stack element being stored in the right-most slot." }
+{ $notes "The " { $snippet "-boa" } " suffix is shorthand for ``by order of arguments'', and ``BOA constructor'' is a pun on ``boa constrictor''." } ;
diff --git a/core/classes/tuple/tuple-tests.factor b/core/classes/tuple/tuple-tests.factor
new file mode 100755 (executable)
index 0000000..2e37655
--- /dev/null
@@ -0,0 +1,378 @@
+USING: definitions generic kernel kernel.private math
+math.constants parser sequences tools.test words assocs
+namespaces quotations sequences.private classes continuations
+generic.standard effects classes.tuple classes.tuple.private
+arrays vectors strings compiler.units accessors classes.algebra
+calendar prettyprint io.streams.string splitting ;
+IN: classes.tuple.tests
+
+TUPLE: rect x y w h ;
+: <rect> rect construct-boa ;
+
+: move ( x rect -- rect )
+    [ + ] change-x ;
+
+[ f ] [ 10 20 30 40 <rect> dup clone 5 swap move = ] unit-test
+
+[ t ] [ 10 20 30 40 <rect> dup clone 0 swap move = ] unit-test
+
+GENERIC: delegation-test
+M: object delegation-test drop 3 ;
+TUPLE: quux-tuple ;
+: <quux-tuple> quux-tuple construct-empty ;
+M: quux-tuple delegation-test drop 4 ;
+TUPLE: quuux-tuple ;
+: <quuux-tuple> { set-delegate } quuux-tuple construct ;
+
+[ 3 ] [ <quux-tuple> <quuux-tuple> delegation-test ] unit-test
+
+GENERIC: delegation-test-2
+TUPLE: quux-tuple-2 ;
+: <quux-tuple-2> quux-tuple-2 construct-empty ;
+M: quux-tuple-2 delegation-test-2 drop 4 ;
+TUPLE: quuux-tuple-2 ;
+: <quuux-tuple-2> { set-delegate } quuux-tuple-2 construct ;
+
+[ 4 ] [ <quux-tuple-2> <quuux-tuple-2> delegation-test-2 ] unit-test
+
+! Make sure we handle tuple class redefinition
+TUPLE: redefinition-test ;
+
+C: <redefinition-test> redefinition-test
+
+<redefinition-test> "redefinition-test" set
+
+[ t ] [ "redefinition-test" get redefinition-test? ] unit-test
+
+"IN: classes.tuple.tests TUPLE: redefinition-test ;" eval
+
+[ t ] [ "redefinition-test" get redefinition-test? ] unit-test
+
+! Make sure we handle changing shapes!
+TUPLE: point x y ;
+
+C: <point> point
+
+[ ] [ 100 200 <point> "p" set ] unit-test
+
+! Use eval to sequence parsing explicitly
+[ ] [ "IN: classes.tuple.tests TUPLE: point x y z ;" eval ] unit-test
+
+[ 100 ] [ "p" get x>> ] unit-test
+[ 200 ] [ "p" get y>> ] unit-test
+[ f ] [ "p" get "z>>" "accessors" lookup execute ] unit-test
+
+"p" get 300 ">>z" "accessors" lookup execute drop
+
+[ 4 ] [ "p" get tuple-size ] unit-test
+
+[ 300 ] [ "p" get "z>>" "accessors" lookup execute ] unit-test
+
+"IN: classes.tuple.tests TUPLE: point z y ;" eval
+
+[ 3 ] [ "p" get tuple-size ] unit-test
+
+[ "p" get x>> ] must-fail
+[ 200 ] [ "p" get y>> ] unit-test
+[ 300 ] [ "p" get "z>>" "accessors" lookup execute ] unit-test
+
+TUPLE: predicate-test ;
+
+C: <predicate-test> predicate-test
+
+: predicate-test drop f ;
+
+[ t ] [ <predicate-test> predicate-test? ] unit-test
+
+PREDICATE: silly-pred < tuple
+    class \ rect = ;
+
+GENERIC: area
+M: silly-pred area dup w>> swap h>> * ;
+
+TUPLE: circle radius ;
+M: circle area radius>> sq pi * ;
+
+[ 200 ] [ T{ rect f 0 0 10 20 } area ] unit-test
+
+! Hashcode breakage
+TUPLE: empty ;
+
+C: <empty> empty
+
+[ t ] [ <empty> hashcode fixnum? ] unit-test
+
+TUPLE: delegate-clone ;
+
+[ T{ delegate-clone T{ empty f } } ]
+[ T{ delegate-clone T{ empty f } } clone ] unit-test
+
+! Compiler regression
+[ t length ] [ object>> t eq? ] must-fail-with
+
+[ "<constructor-test>" ]
+[ "TUPLE: constructor-test ; C: <constructor-test> constructor-test" eval word word-name ] unit-test
+
+TUPLE: size-test a b c d ;
+
+[ t ] [
+    T{ size-test } tuple-size
+    size-test tuple-size =
+] unit-test
+
+GENERIC: <yo-momma>
+
+TUPLE: yo-momma ;
+
+"IN: classes.tuple.tests C: <yo-momma> yo-momma" eval
+
+[ f ] [ \ <yo-momma> generic? ] unit-test
+
+! Test forget
+[
+    [ t ] [ \ yo-momma class? ] unit-test
+    [ ] [ \ yo-momma forget ] unit-test
+    [ f ] [ \ yo-momma update-map get values memq? ] unit-test
+
+    [ f ] [ \ yo-momma crossref get at ] unit-test
+] with-compilation-unit
+
+TUPLE: loc-recording ;
+
+[ f ] [ \ loc-recording where not ] unit-test
+
+! 'forget' wasn't robust enough
+
+TUPLE: forget-robustness ;
+
+GENERIC: forget-robustness-generic
+
+M: forget-robustness forget-robustness-generic ;
+
+M: integer forget-robustness-generic ;
+
+[
+    [ ] [ \ forget-robustness-generic forget ] unit-test
+    [ ] [ \ forget-robustness forget ] unit-test
+    [ ] [ { forget-robustness forget-robustness-generic } forget ] unit-test
+] with-compilation-unit
+
+! rapido found this one
+GENERIC# m1 0 ( s n -- n )
+GENERIC# m2 1 ( s n -- v )
+
+TUPLE: t1 ;
+
+M: t1 m1 drop ;
+M: t1 m2 nip ;
+
+TUPLE: t2 ;
+
+M: t2 m1 drop ;
+M: t2 m2 nip ;
+
+TUPLE: t3 ;
+
+M: t3 m1 drop ;
+M: t3 m2 nip ;
+
+TUPLE: t4 ;
+
+M: t4 m1 drop ;
+M: t4 m2 nip ;
+
+C: <t4> t4
+
+[ 1 ] [ 1 <t4> m1 ] unit-test
+[ 1 ] [ <t4> 1 m2 ] unit-test
+
+! another combination issue
+GENERIC: silly
+
+UNION: my-union slice repetition column array vector reversed ;
+
+M: my-union silly "x" ;
+
+M: array silly "y" ;
+
+M: column silly "fdsfds" ;
+
+M: repetition silly "zzz" ;
+
+M: reversed silly "zz" ;
+
+M: slice silly "tt" ;
+
+M: string silly "t" ;
+
+M: vector silly "z" ;
+
+[ "zz" ] [ 123 <reversed> silly nip ] unit-test
+
+! Typo
+SYMBOL: not-a-tuple-class
+
+[
+    "IN: classes.tuple.tests C: <not-a-tuple-class> not-a-tuple-class"
+    eval
+] must-fail
+
+[ t ] [
+    "not-a-tuple-class" "classes.tuple.tests" lookup symbol?
+] unit-test
+
+! Missing check
+[ not-a-tuple-class construct-boa ] must-fail
+[ not-a-tuple-class construct-empty ] must-fail
+
+TUPLE: erg's-reshape-problem a b c d ;
+
+C: <erg's-reshape-problem> erg's-reshape-problem
+
+! We want to make sure constructors are recompiled when
+! tuples are reshaped
+: cons-test-1 \ erg's-reshape-problem construct-empty ;
+: cons-test-2 \ erg's-reshape-problem construct-boa ;
+
+"IN: classes.tuple.tests TUPLE: erg's-reshape-problem a b c d e f ;" eval
+
+[ ] [ 1 2 3 4 5 6 cons-test-2 "a" set ] unit-test
+
+[ t ] [ cons-test-1 tuple-size "a" get tuple-size = ] unit-test
+
+[
+    "IN: classes.tuple.tests SYMBOL: not-a-class C: <not-a-class> not-a-class" eval
+] [ [ no-tuple-class? ] is? ] must-fail-with
+
+! Inheritance
+TUPLE: computer cpu ram ;
+C: <computer> computer
+
+[ "TUPLE: computer cpu ram ;" ] [
+    [ \ computer see ] with-string-writer string-lines second
+] unit-test
+
+TUPLE: laptop < computer battery ;
+C: <laptop> laptop
+
+[ t ] [ laptop tuple-class? ] unit-test
+[ t ] [ laptop tuple class< ] unit-test
+[ t ] [ laptop computer class< ] unit-test
+[ t ] [ laptop computer classes-intersect? ] unit-test
+
+[ ] [ "Pentium" 128 3 hours <laptop> "laptop" set ] unit-test
+[ t ] [ "laptop" get laptop? ] unit-test
+[ t ] [ "laptop" get computer? ] unit-test
+[ t ] [ "laptop" get tuple? ] unit-test
+
+[ "Pentium" ] [ "laptop" get cpu>> ] unit-test
+[ 128 ] [ "laptop" get ram>> ] unit-test
+[ t ] [ "laptop" get battery>> 3 hours = ] unit-test
+
+[ laptop ] [
+    "laptop" get tuple-layout
+    dup layout-echelon swap
+    layout-superclasses nth
+] unit-test
+
+[ "TUPLE: laptop < computer battery ;" ] [
+    [ \ laptop see ] with-string-writer string-lines second
+] unit-test
+
+[ { tuple computer laptop } ] [ laptop superclasses ] unit-test
+
+TUPLE: server < computer rackmount ;
+C: <server> server
+
+[ t ] [ server tuple-class? ] unit-test
+[ t ] [ server tuple class< ] unit-test
+[ t ] [ server computer class< ] unit-test
+[ t ] [ server computer classes-intersect? ] unit-test
+
+[ ] [ "PowerPC" 64 "1U" <server> "server" set ] unit-test
+[ t ] [ "server" get server? ] unit-test
+[ t ] [ "server" get computer? ] unit-test
+[ t ] [ "server" get tuple? ] unit-test
+
+[ "PowerPC" ] [ "server" get cpu>> ] unit-test
+[ 64 ] [ "server" get ram>> ] unit-test
+[ "1U" ] [ "server" get rackmount>> ] unit-test
+
+[ f ] [ "server" get laptop? ] unit-test
+[ f ] [ "laptop" get server? ] unit-test
+
+[ f ] [ server laptop class< ] unit-test
+[ f ] [ laptop server class< ] unit-test
+[ f ] [ laptop server classes-intersect? ] unit-test
+
+[ f ] [ 1 2 <computer> laptop? ] unit-test
+[ f ] [ \ + server? ] unit-test
+
+[ "TUPLE: server < computer rackmount ;" ] [
+    [ \ server see ] with-string-writer string-lines second
+] unit-test
+
+[
+    "IN: classes.tuple.tests TUPLE: bad-superclass < word ;" eval
+] must-fail
+
+! Reshaping with inheritance
+TUPLE: electronic-device ;
+
+[ ] [ "IN: classes.tuple.tests TUPLE: computer < electronic-device ;" eval ] unit-test
+
+[ f ] [ electronic-device laptop class< ] unit-test
+[ t ] [ server electronic-device class< ] unit-test
+[ t ] [ laptop server class-or electronic-device class< ] unit-test
+
+[ t ] [ "laptop" get electronic-device? ] unit-test
+[ t ] [ "laptop" get computer? ] unit-test
+[ t ] [ "laptop" get laptop? ] unit-test
+[ f ] [ "laptop" get server? ] unit-test
+
+[ t ] [ "server" get electronic-device? ] unit-test
+[ t ] [ "server" get computer? ] unit-test
+[ f ] [ "server" get laptop? ] unit-test
+[ t ] [ "server" get server? ] unit-test
+
+[ ] [ "IN: classes.tuple.tests TUPLE: computer ;" eval ] unit-test
+
+[ f ] [ "laptop" get electronic-device? ] unit-test
+[ t ] [ "laptop" get computer? ] unit-test
+
+! Hardcore unit tests
+USE: threads
+
+\ thread slot-names "slot-names" set
+
+[ ] [
+    [
+        \ thread tuple { "xxx" } "slot-names" get append
+        define-tuple-class
+    ] with-compilation-unit
+
+    [ 1337 sleep ] "Test" spawn drop
+
+    [
+        \ thread tuple "slot-names" get
+        define-tuple-class
+    ] with-compilation-unit
+] unit-test
+
+USE: vocabs
+
+\ vocab slot-names "slot-names" set
+
+[ ] [
+    [
+        \ vocab tuple { "xxx" } "slot-names" get append
+        define-tuple-class
+    ] with-compilation-unit
+
+    all-words drop
+
+    [
+        \ vocab tuple "slot-names" get
+        define-tuple-class
+    ] with-compilation-unit
+] unit-test
diff --git a/core/classes/tuple/tuple.factor b/core/classes/tuple/tuple.factor
new file mode 100755 (executable)
index 0000000..28dbfdb
--- /dev/null
@@ -0,0 +1,219 @@
+! Copyright (C) 2005, 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: arrays definitions hashtables kernel
+kernel.private math namespaces sequences sequences.private
+strings vectors words quotations memory combinators generic
+classes classes.private slots.deprecated slots.private slots
+compiler.units math.private accessors assocs ;
+IN: classes.tuple
+
+M: tuple delegate 2 slot ;
+
+M: tuple set-delegate 2 set-slot ;
+
+M: tuple class 1 slot 2 slot { word } declare ;
+
+ERROR: no-tuple-class class ;
+
+<PRIVATE
+
+GENERIC: tuple-layout ( object -- layout )
+
+M: class tuple-layout "layout" word-prop ;
+
+M: tuple tuple-layout 1 slot ;
+
+: tuple-size tuple-layout layout-size ; inline
+
+PRIVATE>
+
+: check-tuple ( class -- )
+    dup tuple-class?
+    [ drop ] [ no-tuple-class ] if ;
+
+: tuple>array ( tuple -- array )
+    dup tuple-layout
+    [ layout-size swap [ array-nth ] curry map ] keep
+    layout-class add* ;
+
+: >tuple ( seq -- tuple )
+    dup first tuple-layout <tuple> [
+        >r 1 tail-slice dup length r>
+        [ tuple-size min ] keep
+        [ set-array-nth ] curry
+        2each
+    ] keep ;
+
+: slot-names ( class -- seq )
+    "slots" word-prop [ name>> ] map ;
+
+<PRIVATE
+
+: tuple= ( tuple1 tuple2 -- ? )
+    over tuple-layout over tuple-layout eq? [
+        dup tuple-size -rot
+        [ >r over r> array-nth >r array-nth r> = ] 2curry
+        all-integers?
+    ] [
+        2drop f
+    ] if ;
+
+! Predicate generation. We optimize at the expense of simplicity
+
+: (tuple-predicate-quot) ( class -- quot )
+    #! 4 slot == layout-superclasses
+    #! 5 slot == layout-echelon
+    [
+        [ 1 slot dup 5 slot ] %
+        dup tuple-layout layout-echelon ,
+        [ fixnum>= ] %
+        [
+            dup tuple-layout layout-echelon ,
+            [ swap 4 slot array-nth ] %
+            literalize ,
+            [ eq? ] %
+        ] [ ] make ,
+        [ drop f ] ,
+        \ if ,
+    ] [ ] make ;
+
+: tuple-predicate-quot ( class -- quot )
+    [
+        [ dup tuple? ] %
+        (tuple-predicate-quot) ,
+        [ drop f ] ,
+        \ if ,
+    ] [ ] make ;
+
+: define-tuple-predicate ( class -- )
+    dup tuple-predicate-quot define-predicate ;
+
+: superclass-size ( class -- n )
+    superclasses 1 head-slice*
+    [ slot-names length ] map sum ;
+
+: generate-tuple-slots ( class slots -- slots )
+    over superclass-size 2 + simple-slots ;
+
+: define-tuple-slots ( class slots -- )
+    dupd generate-tuple-slots
+    [ "slots" set-word-prop ]
+    [ define-accessors ]
+    [ define-slots ] 2tri ;
+
+: make-tuple-layout ( class -- layout )
+    [ ]
+    [ [ superclass-size ] [ "slots" word-prop length ] bi + ]
+    [ superclasses dup length 1- ] tri
+    <tuple-layout> ;
+
+: define-tuple-layout ( class -- )
+    dup make-tuple-layout "layout" set-word-prop ;
+
+: removed-slots ( class newslots -- seq )
+    swap slot-names seq-diff ;
+
+: forget-slots ( class slots -- )
+    dupd removed-slots [
+        [ reader-word forget-method ]
+        [ writer-word forget-method ] 2bi
+    ] with each ;
+
+: permutation ( seq1 seq2 -- permutation )
+    swap [ index ] curry map ;
+
+: reshape-tuple ( oldtuple permutation -- newtuple )
+    >r tuple>array 2 cut r>
+    [ [ swap ?nth ] [ drop f ] if* ] with map
+    append >tuple ;
+
+: reshape-tuples ( class superclass newslots -- )
+    nip
+    >r dup slot-names r> permutation
+    [
+        >r "predicate" word-prop instances dup
+        r> [ reshape-tuple ] curry map
+        become
+    ] 2curry after-compilation ;
+
+: define-new-tuple-class ( class superclass slots -- )
+    [ drop f tuple-class define-class ]
+    [ nip define-tuple-slots ] [
+        2drop
+        class-usages [
+            drop
+            [ define-tuple-layout ]
+            [ define-tuple-predicate ]
+            bi
+        ] assoc-each
+    ] 3tri ;
+
+: redefine-tuple-class ( class superclass slots -- )
+    [ reshape-tuples ]
+    [
+        nip
+        [ forget-slots ]
+        [ drop changed-word ]
+        [ drop redefined ]
+        2tri
+    ]
+    [ define-new-tuple-class ]
+    3tri ;
+
+: tuple-class-unchanged? ( class superclass slots -- ? )
+    rot tuck [ superclass = ] [ slot-names = ] 2bi* and ;
+
+PRIVATE>
+
+GENERIC# define-tuple-class 2 ( class superclass slots -- )
+
+M: word define-tuple-class
+    define-new-tuple-class ;
+
+M: tuple-class define-tuple-class
+    3dup tuple-class-unchanged?
+    [ 3dup redefine-tuple-class ] unless
+    3drop ;
+
+: define-error-class ( class superclass slots -- )
+    pick >r define-tuple-class r>
+    dup [ construct-boa throw ] curry define ;
+
+M: tuple clone
+    (clone) dup delegate clone over set-delegate ;
+
+M: tuple equal?
+    over tuple? [ tuple= ] [ 2drop f ] if ;
+
+: delegates ( obj -- seq )
+    [ dup ] [ [ delegate ] keep ] [ ] unfold nip ;
+
+: is? ( obj quot -- ? ) >r delegates r> contains? ; inline
+
+M: tuple hashcode*
+    [
+        dup tuple-size -rot 0 -rot [
+            swapd array-nth hashcode* bitxor
+        ] 2curry reduce
+    ] recursive-hashcode ;
+
+: tuple-slots ( tuple -- seq ) tuple>array 2 tail ;
+
+! Definition protocol
+M: tuple-class reset-class
+    { "metaclass" "superclass" "slots" "layout" } reset-props ;
+
+M: object get-slots ( obj slots -- ... )
+    [ execute ] with each ;
+
+M: object set-slots ( ... obj slots -- )
+    <reversed> get-slots ;
+
+M: object construct-empty ( class -- tuple )
+    tuple-layout <tuple> ;
+
+M: object construct ( ... slots class -- tuple )
+    construct-empty [ swap set-slots ] keep ;
+
+M: object construct-boa ( ... class -- tuple )
+    tuple-layout <tuple-boa> ;
index 29210afaa55bc89c7a0b36590fa12f9cdffdd810..e9902888eb7114247dc6d4ebe01a538dece3475b 100755 (executable)
@@ -5,8 +5,8 @@ cpu.arm.architecture cpu.arm.allot kernel kernel.private math
 math.private namespaces sequences words
 quotations byte-arrays hashtables.private hashtables generator
 generator.registers generator.fixup sequences.private sbufs
-sbufs.private vectors vectors.private system tuples.private
-layouts strings.private slots.private ;
+sbufs.private vectors vectors.private system
+classes.tuple.private layouts strings.private slots.private ;
 IN: cpu.arm.intrinsics
 
 : %slot-literal-known-tag
index 0aef15ba99faad08a254f38efced306670ede08f..7aa78ce52e4e396bc13a704332b2e6c3846679e7 100755 (executable)
@@ -6,9 +6,9 @@ kernel.private math math.private namespaces sequences words
 generic quotations byte-arrays hashtables hashtables.private
 generator generator.registers generator.fixup sequences.private
 sbufs vectors system layouts math.floats.private
-classes tuples tuples.private sbufs.private vectors.private
-strings.private slots.private combinators bit-arrays
-float-arrays compiler.constants ;
+classes classes.tuple classes.tuple.private sbufs.private
+vectors.private strings.private slots.private combinators
+bit-arrays float-arrays compiler.constants ;
 IN: cpu.ppc.intrinsics
 
 : %slot-literal-known-tag
index dfe136fc6ee97c79b8e4146beebbcf771ac59d82..f5409a24f54d3065eb09c4d27c46550f8634fdd8 100755 (executable)
@@ -6,8 +6,8 @@ kernel.private math math.private namespaces quotations sequences
 words generic byte-arrays hashtables hashtables.private
 generator generator.registers generator.fixup sequences.private
 sbufs sbufs.private vectors vectors.private layouts system
-tuples.private strings.private slots.private compiler.constants
-;
+classes.tuple.private strings.private slots.private
+compiler.constants ;
 IN: cpu.x86.intrinsics
 
 ! Type checks
index 3361073d354b5253fdc7ca009e5dba406130f882..a7937cdb9dbbd415dd1f95fd2b81c11aad0cf986 100755 (executable)
@@ -3,7 +3,7 @@
 USING: arrays definitions generic hashtables inspector io kernel
 math namespaces prettyprint sequences assocs sequences.private
 strings io.styles vectors words system splitting math.parser
-tuples continuations continuations.private combinators
+classes.tuple continuations continuations.private combinators
 generic.math io.streams.duplex classes compiler.units
 generic.standard vocabs threads threads.private init
 kernel.private libc io.encodings ;
index 4f5d19926470d1e47f64efd35cf595eba617f26b..1cc1548a3dbc9b1edc15946395cf1789bd1b1d38 100755 (executable)
@@ -3,9 +3,9 @@ inference.dataflow kernel classes kernel.private math
 math.parser math.private namespaces namespaces.private parser
 sequences strings vectors words quotations effects tools.test
 continuations generic.standard sorting assocs definitions
-prettyprint io inspector tuples classes.union classes.predicate
-debugger threads.private io.streams.string io.timeouts
-io.thread sequences.private ;
+prettyprint io inspector classes.tuple classes.union
+classes.predicate debugger threads.private io.streams.string
+io.timeouts io.thread sequences.private ;
 IN: inference.tests
 
 { 0 2 } [ 2 "Hello" ] must-infer-as
index 0de1e0bc53175cbdfb9cf0b27d323d80eb48165e..79e41c8ae45c2b7b0c29235b051ea01c48332516 100755 (executable)
@@ -9,9 +9,9 @@ kernel.private math math.private memory namespaces
 namespaces.private parser prettyprint quotations
 quotations.private sbufs sbufs.private sequences
 sequences.private slots.private strings strings.private system
-threads.private tuples tuples.private vectors vectors.private
-words words.private assocs inspector compiler.units
-system.private ;
+threads.private classes.tuple classes.tuple.private vectors
+vectors.private words words.private assocs inspector
+compiler.units system.private ;
 IN: inference.known-words
 
 ! Shuffle words
index e77872ae78b051d57fed91f0baf0878cbff31826..200208c6a5be9eb1032121134ee74f8277d545ea 100755 (executable)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays kernel words sequences generic math namespaces
 quotations assocs combinators math.bitfields inference.backend
-inference.dataflow inference.state tuples.private effects
+inference.dataflow inference.state classes.tuple.private effects
 inspector hashtables ;
 IN: inference.transforms
 
index 1987597c58df2fa39dec110610276dbaf777ec26..cbabeb6bfa7a9ed225a653adbe15eaacb7d5b549 100755 (executable)
@@ -156,8 +156,6 @@ GENERIC: construct-boa ( ... class -- tuple )
     >r { set-delegate } r> construct ; inline
 
 ! Quotation building
-USE: tuples.private
-
 : 2curry ( obj1 obj2 quot -- curry )
     curry curry ; inline
 
index 16ee2705fe14d49bc8ac8773d42e46a233e6617d..bf262b77a26be3d0e8b19dbfba122b944da28710 100755 (executable)
@@ -3,7 +3,7 @@
 USING: arrays hashtables io kernel math math.parser memory
 namespaces parser sequences strings io.styles
 io.streams.duplex vectors words generic system combinators
-tuples continuations debugger definitions compiler.units ;
+continuations debugger definitions compiler.units ;
 IN: listener
 
 SYMBOL: quit-flag
index 3c5a0aa3c7d4627fac23089f197965f4a5232bf5..fde8728858dce4a10236d66c51f6f47d6080b267 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: assocs hashtables kernel sequences generic words
-arrays classes slots slots.private tuples math vectors
+arrays classes slots slots.private classes.tuple math vectors
 quotations sorting prettyprint ;
 IN: mirrors
 
index b56f6fdb06a947d677686a3b65f89f29e957aa29..aef48452de11a94905152fba478fe744596f7d9a 100755 (executable)
@@ -6,7 +6,7 @@ inference.class kernel assocs math math.private kernel.private
 sequences words parser vectors strings sbufs io namespaces
 assocs quotations sequences.private io.binary io.crc32
 io.streams.string layouts splitting math.intervals
-math.floats.private tuples tuples.private classes
+math.floats.private classes.tuple classes.tuple.private classes
 classes.algebra optimizer.def-use optimizer.backend
 optimizer.pattern-match optimizer.inlining float-arrays
 sequences.private combinators ;
index 89cea45aee89cbfab461adb012c8baf0002492b5..aa081e8e2cee4654c024d329017effdea72980d9 100755 (executable)
@@ -2,7 +2,7 @@ USING: arrays compiler.units generic hashtables inference kernel
 kernel.private math optimizer prettyprint sequences sbufs
 strings tools.test vectors words sequences.private quotations
 optimizer.backend classes classes.algebra inference.dataflow
-tuples.private continuations growable optimizer.inlining
+classes.tuple.private continuations growable optimizer.inlining
 namespaces hints ;
 IN: optimizer.tests
 
index 670740fff0da13f7a5a0ea5cf148253747eaf88e..a15da827189bf278164c7b2c4b61d6634433232d 100755 (executable)
@@ -1,7 +1,8 @@
 USING: arrays math parser tools.test kernel generic words
 io.streams.string namespaces classes effects source-files
 assocs sequences strings io.files definitions continuations
-sorting tuples compiler.units debugger vocabs vocabs.loader ;
+sorting classes.tuple compiler.units debugger vocabs
+vocabs.loader ;
 IN: parser.tests
 
 [
index 5d7b967fc43c47c6d5c5176fc4f8e9efbe665adc..c9019b029d70dd486cb077f79f38cb4b7fa38c00 100755 (executable)
@@ -4,7 +4,8 @@ USING: arrays byte-arrays byte-vectors bit-arrays bit-vectors
 generic hashtables io assocs kernel math namespaces sequences
 strings sbufs io.styles vectors words prettyprint.config
 prettyprint.sections quotations io io.files math.parser effects
-tuples tuples.private classes float-arrays float-vectors ;
+classes.tuple classes.tuple.private classes float-arrays
+float-vectors ;
 IN: prettyprint.backend
 
 GENERIC: pprint* ( obj -- )
index 675841816f1f4eba663d135d63f9910eb62a04ca..6c557d873de207d3d9b9d10a59ea3bbcdbcb1c99 100755 (executable)
@@ -1,11 +1,11 @@
-! Copyright (C) 2003, 2007 Slava Pestov.
+! Copyright (C) 2003, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 IN: prettyprint
 USING: alien arrays generic generic.standard assocs io kernel
 math namespaces sequences strings io.styles io.streams.string
 vectors words prettyprint.backend prettyprint.sections
 prettyprint.config sorting splitting math.parser vocabs
-definitions effects tuples io.files classes continuations
+definitions effects classes.tuple io.files classes continuations
 hashtables classes.mixin classes.union classes.predicate
 combinators quotations ;
 
index fb67db93329980eb4da2a071e39ffd613a3f8b7c..c52c5daf9e77d72116e137ca47788eec419cc4bc 100644 (file)
@@ -1,6 +1,6 @@
-! Copyright (C) 2007 Slava Pestov
+! Copyright (C) 2007, 2008 Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
-USING: tuples kernel assocs ;
+USING: classes.tuple kernel assocs accessors ;
 IN: refs
 
 TUPLE: ref assoc key ;
@@ -8,7 +8,7 @@ TUPLE: ref assoc key ;
 : <ref> ( assoc key class -- tuple )
     >r ref construct-boa r> construct-delegate ; inline
 
-: >ref< ( ref -- key assoc ) dup ref-key swap ref-assoc ;
+: >ref< ( ref -- key assoc ) [ key>> ] [ assoc>> ] bi ;
 
 : delete-ref ( ref -- ) >ref< delete-at ;
 GENERIC: get-ref ( ref -- obj )
index 5de765313b52b1f9783ab655bc1ad671eac9a057..2b0d721f3e87c87ca424fa5c2a555bf3760d19b7 100755 (executable)
@@ -1,6 +1,6 @@
 USING: help.markup help.syntax generic kernel.private parser
 words kernel quotations namespaces sequences words arrays
-effects generic.standard tuples slots.private classes
+effects generic.standard classes.tuple slots.private classes
 strings math ;
 IN: slots
 
index 3874cecf71b734882eb75f1a1d39aaf21675f3a6..bd349953df9b1feae3fd638ba590808a5fc2d4bc 100755 (executable)
@@ -1,6 +1,6 @@
 USING: generic help.syntax help.markup kernel math parser words
-effects classes generic.standard tuples generic.math arrays
-io.files vocabs.loader io sequences assocs ;
+effects classes generic.standard classes.tuple generic.math
+arrays io.files vocabs.loader io sequences assocs ;
 IN: syntax
 
 ARTICLE: "parser-algorithm" "Parser algorithm"
index 5da2d5e4e2143550491c5e63a5445f8be38c6a30..19fdf0e45f2fb58999c05998d055d7368de04f01 100755 (executable)
@@ -3,7 +3,7 @@
 USING: alien arrays bit-arrays bit-vectors byte-arrays
 byte-vectors definitions generic hashtables kernel math
 namespaces parser sequences strings sbufs vectors words
-quotations io assocs splitting tuples generic.standard
+quotations io assocs splitting classes.tuple generic.standard
 generic.math classes io.files vocabs float-arrays float-vectors
 classes.union classes.mixin classes.predicate compiler.units
 combinators debugger ;
diff --git a/core/tuples/authors.txt b/core/tuples/authors.txt
deleted file mode 100644 (file)
index 1901f27..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Slava Pestov
diff --git a/core/tuples/summary.txt b/core/tuples/summary.txt
deleted file mode 100644 (file)
index 4dbb643..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Object system implementation
diff --git a/core/tuples/tuples-docs.factor b/core/tuples/tuples-docs.factor
deleted file mode 100755 (executable)
index 55e15d6..0000000
+++ /dev/null
@@ -1,290 +0,0 @@
-USING: generic help.markup help.syntax kernel
-tuples.private classes slots quotations words arrays
-generic.standard sequences definitions compiler.units ;
-IN: tuples
-
-ARTICLE: "tuple-constructors" "Constructors"
-"Tuples are created by calling one of two words:"
-{ $subsection construct-empty }
-{ $subsection construct-boa }
-"By convention, construction logic is encapsulated in a word named after the tuple class surrounded in angle brackets; for example, the constructor word for a " { $snippet "point" } " class might be named " { $snippet "<point>" } "."
-$nl
-"A shortcut for defining BOA constructors:"
-{ $subsection POSTPONE: C: }
-"Examples of constructors:"
-{ $code
-    "TUPLE: color red green blue alpha ;"
-    ""
-    "C: <rgba> rgba"
-    ": <rgba> color construct-boa ; ! identical to above"
-    ""
-    ": <rgb> f <rgba> ;"
-    ""
-    ": <color> construct-empty ;"
-    ": <color> f f f f <rgba> ; ! identical to above"
-} ;
-
-ARTICLE: "tuple-delegation" "Tuple delegation"
-"If a generic word having the " { $link standard-combination } " method combination is called on a tuple for which it does not have an applicable method, the method call is forwarded to the tuple's " { $emphasis "delegate" } ". If no delegate is set, a " { $link no-method } " error is thrown."
-{ $subsection delegate }
-{ $subsection set-delegate }
-"A tuple's delegate should either be another tuple, or " { $link f } ", indicating no delegate is set. Delegation from a tuple to an object of some other type is not fully supported and should be used with caution."
-$nl
-"Factor uses delegation in place of implementation inheritance, but it is not a direct substitute; in particular, the semantics differ in that a delegated method call receives the delegate on the stack, not the original object."
-$nl
-"A pair of words examine delegation chains:"
-{ $subsection delegates }
-{ $subsection is? }
-"An example:"
-{ $example
-    "TUPLE: ellipse center radius ;"
-    "TUPLE: colored color ;"
-    "{ 0 0 } 10 <ellipse> \"my-ellipse\" set"
-    "{ 1 0 0 } <colored> \"my-shape\" set"
-    "\"my-ellipse\" get \"my-shape\" get set-delegate"
-    "\"my-shape\" get dup color>> swap center>> .s"
-    "{ 0 0 }\n{ 1 0 0 }"
-} ;
-
-ARTICLE: "tuple-introspection" "Tuple introspection"
-"In addition to the slot reader and writer words which " { $link POSTPONE: TUPLE: } " defines for every tuple class, it is possible to construct and take apart entire tuples in a generic way."
-{ $subsection >tuple }
-{ $subsection tuple>array }
-{ $subsection tuple-slots }
-"Tuple classes can also be defined at run time:"
-{ $subsection define-tuple-class }
-{ $see-also "slots" "mirrors" } ;
-
-ARTICLE: "tuple-examples" "Tuple examples"
-"An example:"
-{ $code "TUPLE: employee name salary position ;" }
-"This defines a class word named " { $snippet "employee" } ", a predicate " { $snippet "employee?" } ", and the following slot accessors:"
-{ $table
-    { "Reader" "Writer" "Setter" "Changer" }
-    { { $snippet "name>>" }    { $snippet "(>>name)" }    { $snippet ">>name" }    { $snippet "change-name" }    }
-    { { $snippet "salary>>" } { $snippet "(>>salary)" } { $snippet ">>salary" } { $snippet "change-salary" } }
-    { { $snippet "position>>" }   { $snippet "(>>position)" }   { $snippet ">>position" }   { $snippet "change-position" }   }
-}
-"We can define a constructor which makes an empty employee:"
-{ $code ": <employee> ( -- employee )"
-    "    employee construct-empty ;" }
-"Or we may wish the default constructor to always give employees a starting salary:"
-{ $code
-    ": <employee> ( -- employee )"
-    "    employee construct-empty"
-    "        40000 >>salary ;"
-}
-"We can define more refined constructors:"
-{ $code
-    ": <manager> ( -- manager )"
-    "    <employee> \"project manager\" >>position ;" }
-"An alternative strategy is to define the most general BOA constructor first:"
-{ $code
-    ": <employee> ( name position -- person )"
-    "    40000 employee construct-boa ;"
-}
-"Now we can define more specific constructors:"
-{ $code
-    ": <manager> ( name -- person )"
-    "    \"manager\" <person> ;" }
-"An example using reader words:"
-{ $code
-    "TUPLE: check to amount number ;"
-    ""
-    "SYMBOL: checks"
-    ""
-    ": <check> ( to amount -- check )"
-    "    checks counter check construct-boa ;"
-    ""
-    ": biweekly-paycheck ( employee -- check )"
-    "    dup name>> swap salary>> 26 / <check> ;"
-}
-"An example of using a changer:"
-{ $code
-    ": positions"
-    "    {"
-    "        \"junior programmer\""
-    "        \"senior programmer\""
-    "        \"project manager\""
-    "        \"department manager\""
-    "        \"executive\""
-    "        \"CTO\""
-    "        \"CEO\""
-    "        \"enterprise Java world dictator\""
-    "    } ;"
-    ""
-    ": next-position ( role -- newrole )"
-    "    positions [ index 1+ ] keep nth ;"
-    ""
-    ": promote ( person -- person )"
-    "    [ 1.2 * ] change-salary"
-    "    [ next-position ] change-position ;"
-} ;
-
-ARTICLE: "tuples" "Tuples"
-"Tuples are user-defined classes composed of named slots."
-{ $subsection "tuple-examples" }
-"A parsing word defines tuple classes:"
-{ $subsection POSTPONE: TUPLE: }
-"For each tuple class, several words are defined. First, there is the class word, a class predicate, and accessor words for each slot."
-$nl
-"The class word is used for defining methods on the tuple class; it has the same name as the tuple class. The predicate is named " { $snippet { $emphasis "name" } "?" } ". Tuple slots are accessed via accessor words:"
-{ $subsection "accessors" }
-"Initially, no specific words are defined for constructing new instances of the tuple. Constructors must be defined explicitly:"
-{ $subsection "tuple-constructors" }
-"Further topics:"
-{ $subsection "tuple-delegation" }
-{ $subsection "tuple-introspection" }
-"Tuple literal syntax is documented in " { $link "syntax-tuples" } "." ;
-
-ABOUT: "tuples"
-
-HELP: delegate
-{ $values { "obj" object } { "delegate" object } }
-{ $description "Returns an object's delegate, or " { $link f } " if no delegate is set." }
-{ $notes "A direct consequence of this behavior is that an object may not have a delegate of " { $link f } "." } ;
-
-HELP: set-delegate
-{ $values { "delegate" object } { "tuple" tuple } }
-{ $description "Sets a tuple's delegate. Method calls not handled by the tuple's class will now be passed on to the delegate." } ;
-
-HELP: tuple=
-{ $values { "tuple1" tuple } { "tuple2" tuple } { "?" "a boolean" } }
-{ $description "Low-level tuple equality test. User code should use " { $link = } " instead." }
-{ $warning "This word is in the " { $vocab-link "tuples.private" } " vocabulary because it does not do any type checking. Passing values which are not tuples can result in memory corruption." } ;
-
-HELP: permutation
-{ $values { "seq1" sequence } { "seq2" sequence } { "permutation" "a sequence whose elements are integers or " { $link f } } }
-{ $description "Outputs a permutation for taking " { $snippet "seq1" } " to " { $snippet "seq2" } "." } ;
-
-HELP: reshape-tuple
-{ $values { "oldtuple" tuple } { "permutation" "a sequence whose elements are integers or " { $link f } } { "newtuple" tuple } }
-{ $description "Permutes the slots of a tuple. If a tuple class is redefined at runtime, this word is called on every instance to change its shape to conform to the new layout." } ;
-
-HELP: reshape-tuples
-{ $values { "class" tuple-class } { "newslots" "a sequence of strings" } }
-{ $description "Changes the shape of every instance of " { $snippet "class" } " for a new slot layout." } ;
-
-HELP: removed-slots
-{ $values { "class" tuple-class } { "newslots" "a sequence of strings" } { "seq" "a sequence of strings" } }
-{ $description "Outputs the sequence of existing tuple slot names not in " { $snippet "newslots" } "." } ;
-
-HELP: forget-slots
-{ $values { "class" tuple-class } { "newslots" "a sequence of strings" } }
-{ $description "Forgets accessor words for existing tuple slots which are not in " { $snippet "newslots" } "." } ;
-
-HELP: tuple
-{ $class-description "The class of tuples. This class is further partitioned into disjoint subclasses; each tuple shape defined by " { $link POSTPONE: TUPLE: } " is a new class."
-$nl
-"Tuple classes have additional word properties:"
-{ $list
-    { { $snippet "\"constructor\"" } " - a word for creating instances of this tuple class" }
-    { { $snippet "\"predicate\"" } " - a quotation which tests if the top of the stack is an instance of this tuple class" }
-    { { $snippet "\"slots\"" } " - a sequence of " { $link slot-spec } " instances" }
-    { { $snippet "\"slot-names\"" } " - a sequence of strings naming the tuple's slots" }
-    { { $snippet "\"tuple-size\"" } " - the number of slots" }
-} } ;
-
-HELP: define-tuple-predicate
-{ $values { "class" tuple-class } }
-{ $description "Defines a predicate word that tests if the top of the stack is an instance of " { $snippet "class" } ". This will only work if " { $snippet "class" } " is a tuple class." }
-$low-level-note ;
-
-HELP: redefine-tuple-class
-{ $values { "class" class } { "superclass" class } { "slots" "a sequence of strings" } }
-{ $description "If the new slot layout differs from the existing one, updates all existing instances of this tuple class, and forgets any slot accessor words which are no longer needed."
-$nl
-"If the class is not a tuple class word, this word does nothing." }
-$low-level-note ;
-
-HELP: tuple-slots
-{ $values { "tuple" tuple } { "seq" sequence } }
-{ $description "Pushes a sequence of tuple slot values, not including the tuple class word and delegate." } ;
-
-{ tuple-slots tuple>array } related-words
-
-HELP: define-tuple-slots
-{ $values { "class" tuple-class } { "slots" "a sequence of strings" } }
-{ $description "Defines slot accessor and mutator words for the tuple." }
-$low-level-note ;
-
-HELP: check-tuple
-{ $values { "class" class } }
-{ $description "Throws a " { $link check-tuple } " error if " { $snippet "word" } " is not a tuple class word." }
-{ $error-description "Thrown if " { $link POSTPONE: C: } " is called with a word which does not name a tuple class." } ;
-
-HELP: define-tuple-class
-{ $values { "class" word } { "superclass" class } { "slots" "a sequence of strings" } }
-{ $description "Defines a tuple class inheriting from " { $snippet "superclass" } " with slots named by " { $snippet "slots" } ". This is the run time equivalent of " { $link POSTPONE: TUPLE: } "." }
-{ $notes "This word must be called from inside " { $link with-compilation-unit } "." }
-{ $side-effects "class" } ;
-
-{ tuple-class define-tuple-class POSTPONE: TUPLE: } related-words
-
-HELP: delegates
-{ $values { "obj" object } { "seq" sequence } }
-{ $description "Outputs the delegation chain of an object. The first element of " { $snippet "seq" } " is " { $snippet "obj" } " itself. If " { $snippet "obj" } " is " { $link f } ", an empty sequence is output." } ;
-
-HELP: is?
-{ $values { "obj" object } { "quot" "a quotation with stack effect " { $snippet "( obj -- ? )" } } { "?" "a boolean" } }
-{ $description "Tests if the object or one of its delegates satisfies the predicate quotation."
-$nl
-"Class membership test predicates only test if an object is a direct instance of that class. Sometimes, you need to check delegates, since this gives a clearer picture of what operations the object supports." } ;
-
-HELP: >tuple
-{ $values { "seq" sequence } { "tuple" tuple } }
-{ $description "Creates a tuple with slot values taken from a sequence. The first element of the sequence must be a tuple class word, the second a delegate, and the remainder the declared slots."
-$nl
-"If the sequence has too many elements, they are ignored, and if it has too few, the remaining slots in the tuple are set to " { $link f } "." }
-{ $errors "Throws an error if the first element of the sequence is not a tuple class word." } ;
-
-HELP: tuple>array ( tuple -- array )
-{ $values { "tuple" tuple } { "array" array } }
-{ $description "Outputs an array having the tuple's slots as elements. The first element is the tuple class word and the second is the delegate; the remainder are declared slots." } ;
-
-HELP: <tuple> ( layout -- tuple )
-{ $values { "layout" tuple-layout } { "tuple" tuple } }
-{ $description "Low-level tuple constructor. User code should never call this directly, and instead use " { $link construct-empty } "." } ;
-
-HELP: <tuple-boa> ( ... layout -- tuple )
-{ $values { "..." "values" } { "layout" tuple-layout } { "tuple" tuple } }
-{ $description "Low-level tuple constructor. User code should never call this directly, and instead use " { $link construct-boa } "." } ;
-
-HELP: construct-empty
-{ $values { "class" tuple-class } { "tuple" tuple } }
-{ $description "Creates a new instance of " { $snippet "class" } " with all slots initially set to " { $link f } "." }
-{ $examples
-    { $example
-        "USING: kernel prettyprint ;"
-        "TUPLE: employee number name department ;"
-        "employee construct-empty ."
-        "T{ employee f f f f }"
-    }
-} ;
-
-HELP: construct
-{ $values { "..." "slot values" } { "slots" "a sequence of setter words" } { "class" tuple-class } { "tuple" tuple } }
-{ $description "Creates a new instance of " { $snippet "class" } ", storing consecutive stack values into the slots of the new tuple using setter words in " { $snippet "slots" } ". The top-most stack element is stored in the right-most slot." }
-{ $examples
-    "We can define a class:"
-    { $code "TUPLE: color red green blue alpha ;" }
-    "Together with two constructors:"
-    { $code
-        ": <rgb> ( r g b -- color )"
-        "    { set-color-red set-color-green set-color-blue }"
-        "    color construct ;"
-        ""
-        ": <rgba> ( r g b a -- color )"
-        "    { set-color-red set-color-green set-color-blue set-color-alpha }"
-        "    color construct ;"
-    }
-    "The last definition is actually equivalent to the following:"
-    { $code ": <rgba> ( r g b a -- color ) rgba construct-boa ;" }
-    "Which can be abbreviated further:"
-    { $code "C: <rgba> color" }
-} ;
-
-HELP: construct-boa
-{ $values { "..." "slot values" } { "class" tuple-class } { "tuple" tuple } }
-{ $description "Creates a new instance of " { $snippet "class" } " and fill in the slots from the stack, with the top-most stack element being stored in the right-most slot." }
-{ $notes "The " { $snippet "-boa" } " suffix is shorthand for ``by order of arguments'', and ``BOA constructor'' is a pun on ``boa constrictor''." } ;
diff --git a/core/tuples/tuples-tests.factor b/core/tuples/tuples-tests.factor
deleted file mode 100755 (executable)
index 2ae53ee..0000000
+++ /dev/null
@@ -1,378 +0,0 @@
-USING: definitions generic kernel kernel.private math
-math.constants parser sequences tools.test words assocs
-namespaces quotations sequences.private classes continuations
-generic.standard effects tuples tuples.private arrays vectors
-strings compiler.units accessors classes.algebra calendar
-prettyprint io.streams.string splitting ;
-IN: tuples.tests
-
-TUPLE: rect x y w h ;
-: <rect> rect construct-boa ;
-
-: move ( x rect -- rect )
-    [ + ] change-x ;
-
-[ f ] [ 10 20 30 40 <rect> dup clone 5 swap move = ] unit-test
-
-[ t ] [ 10 20 30 40 <rect> dup clone 0 swap move = ] unit-test
-
-GENERIC: delegation-test
-M: object delegation-test drop 3 ;
-TUPLE: quux-tuple ;
-: <quux-tuple> quux-tuple construct-empty ;
-M: quux-tuple delegation-test drop 4 ;
-TUPLE: quuux-tuple ;
-: <quuux-tuple> { set-delegate } quuux-tuple construct ;
-
-[ 3 ] [ <quux-tuple> <quuux-tuple> delegation-test ] unit-test
-
-GENERIC: delegation-test-2
-TUPLE: quux-tuple-2 ;
-: <quux-tuple-2> quux-tuple-2 construct-empty ;
-M: quux-tuple-2 delegation-test-2 drop 4 ;
-TUPLE: quuux-tuple-2 ;
-: <quuux-tuple-2> { set-delegate } quuux-tuple-2 construct ;
-
-[ 4 ] [ <quux-tuple-2> <quuux-tuple-2> delegation-test-2 ] unit-test
-
-! Make sure we handle tuple class redefinition
-TUPLE: redefinition-test ;
-
-C: <redefinition-test> redefinition-test
-
-<redefinition-test> "redefinition-test" set
-
-[ t ] [ "redefinition-test" get redefinition-test? ] unit-test
-
-"IN: tuples.tests TUPLE: redefinition-test ;" eval
-
-[ t ] [ "redefinition-test" get redefinition-test? ] unit-test
-
-! Make sure we handle changing shapes!
-TUPLE: point x y ;
-
-C: <point> point
-
-[ ] [ 100 200 <point> "p" set ] unit-test
-
-! Use eval to sequence parsing explicitly
-[ ] [ "IN: tuples.tests TUPLE: point x y z ;" eval ] unit-test
-
-[ 100 ] [ "p" get x>> ] unit-test
-[ 200 ] [ "p" get y>> ] unit-test
-[ f ] [ "p" get "z>>" "accessors" lookup execute ] unit-test
-
-"p" get 300 ">>z" "accessors" lookup execute drop
-
-[ 4 ] [ "p" get tuple-size ] unit-test
-
-[ 300 ] [ "p" get "z>>" "accessors" lookup execute ] unit-test
-
-"IN: tuples.tests TUPLE: point z y ;" eval
-
-[ 3 ] [ "p" get tuple-size ] unit-test
-
-[ "p" get x>> ] must-fail
-[ 200 ] [ "p" get y>> ] unit-test
-[ 300 ] [ "p" get "z>>" "accessors" lookup execute ] unit-test
-
-TUPLE: predicate-test ;
-
-C: <predicate-test> predicate-test
-
-: predicate-test drop f ;
-
-[ t ] [ <predicate-test> predicate-test? ] unit-test
-
-PREDICATE: silly-pred < tuple
-    class \ rect = ;
-
-GENERIC: area
-M: silly-pred area dup w>> swap h>> * ;
-
-TUPLE: circle radius ;
-M: circle area radius>> sq pi * ;
-
-[ 200 ] [ T{ rect f 0 0 10 20 } area ] unit-test
-
-! Hashcode breakage
-TUPLE: empty ;
-
-C: <empty> empty
-
-[ t ] [ <empty> hashcode fixnum? ] unit-test
-
-TUPLE: delegate-clone ;
-
-[ T{ delegate-clone T{ empty f } } ]
-[ T{ delegate-clone T{ empty f } } clone ] unit-test
-
-! Compiler regression
-[ t length ] [ object>> t eq? ] must-fail-with
-
-[ "<constructor-test>" ]
-[ "TUPLE: constructor-test ; C: <constructor-test> constructor-test" eval word word-name ] unit-test
-
-TUPLE: size-test a b c d ;
-
-[ t ] [
-    T{ size-test } tuple-size
-    size-test tuple-size =
-] unit-test
-
-GENERIC: <yo-momma>
-
-TUPLE: yo-momma ;
-
-"IN: tuples.tests C: <yo-momma> yo-momma" eval
-
-[ f ] [ \ <yo-momma> generic? ] unit-test
-
-! Test forget
-[
-    [ t ] [ \ yo-momma class? ] unit-test
-    [ ] [ \ yo-momma forget ] unit-test
-    [ f ] [ \ yo-momma update-map get values memq? ] unit-test
-
-    [ f ] [ \ yo-momma crossref get at ] unit-test
-] with-compilation-unit
-
-TUPLE: loc-recording ;
-
-[ f ] [ \ loc-recording where not ] unit-test
-
-! 'forget' wasn't robust enough
-
-TUPLE: forget-robustness ;
-
-GENERIC: forget-robustness-generic
-
-M: forget-robustness forget-robustness-generic ;
-
-M: integer forget-robustness-generic ;
-
-[
-    [ ] [ \ forget-robustness-generic forget ] unit-test
-    [ ] [ \ forget-robustness forget ] unit-test
-    [ ] [ { forget-robustness forget-robustness-generic } forget ] unit-test
-] with-compilation-unit
-
-! rapido found this one
-GENERIC# m1 0 ( s n -- n )
-GENERIC# m2 1 ( s n -- v )
-
-TUPLE: t1 ;
-
-M: t1 m1 drop ;
-M: t1 m2 nip ;
-
-TUPLE: t2 ;
-
-M: t2 m1 drop ;
-M: t2 m2 nip ;
-
-TUPLE: t3 ;
-
-M: t3 m1 drop ;
-M: t3 m2 nip ;
-
-TUPLE: t4 ;
-
-M: t4 m1 drop ;
-M: t4 m2 nip ;
-
-C: <t4> t4
-
-[ 1 ] [ 1 <t4> m1 ] unit-test
-[ 1 ] [ <t4> 1 m2 ] unit-test
-
-! another combination issue
-GENERIC: silly
-
-UNION: my-union slice repetition column array vector reversed ;
-
-M: my-union silly "x" ;
-
-M: array silly "y" ;
-
-M: column silly "fdsfds" ;
-
-M: repetition silly "zzz" ;
-
-M: reversed silly "zz" ;
-
-M: slice silly "tt" ;
-
-M: string silly "t" ;
-
-M: vector silly "z" ;
-
-[ "zz" ] [ 123 <reversed> silly nip ] unit-test
-
-! Typo
-SYMBOL: not-a-tuple-class
-
-[
-    "IN: tuples.tests C: <not-a-tuple-class> not-a-tuple-class"
-    eval
-] must-fail
-
-[ t ] [
-    "not-a-tuple-class" "tuples.tests" lookup symbol?
-] unit-test
-
-! Missing check
-[ not-a-tuple-class construct-boa ] must-fail
-[ not-a-tuple-class construct-empty ] must-fail
-
-TUPLE: erg's-reshape-problem a b c d ;
-
-C: <erg's-reshape-problem> erg's-reshape-problem
-
-! We want to make sure constructors are recompiled when
-! tuples are reshaped
-: cons-test-1 \ erg's-reshape-problem construct-empty ;
-: cons-test-2 \ erg's-reshape-problem construct-boa ;
-
-"IN: tuples.tests TUPLE: erg's-reshape-problem a b c d e f ;" eval
-
-[ ] [ 1 2 3 4 5 6 cons-test-2 "a" set ] unit-test
-
-[ t ] [ cons-test-1 tuple-size "a" get tuple-size = ] unit-test
-
-[
-    "IN: tuples.tests SYMBOL: not-a-class C: <not-a-class> not-a-class" eval
-] [ [ no-tuple-class? ] is? ] must-fail-with
-
-! Inheritance
-TUPLE: computer cpu ram ;
-C: <computer> computer
-
-[ "TUPLE: computer cpu ram ;" ] [
-    [ \ computer see ] with-string-writer string-lines second
-] unit-test
-
-TUPLE: laptop < computer battery ;
-C: <laptop> laptop
-
-[ t ] [ laptop tuple-class? ] unit-test
-[ t ] [ laptop tuple class< ] unit-test
-[ t ] [ laptop computer class< ] unit-test
-[ t ] [ laptop computer classes-intersect? ] unit-test
-
-[ ] [ "Pentium" 128 3 hours <laptop> "laptop" set ] unit-test
-[ t ] [ "laptop" get laptop? ] unit-test
-[ t ] [ "laptop" get computer? ] unit-test
-[ t ] [ "laptop" get tuple? ] unit-test
-
-[ "Pentium" ] [ "laptop" get cpu>> ] unit-test
-[ 128 ] [ "laptop" get ram>> ] unit-test
-[ t ] [ "laptop" get battery>> 3 hours = ] unit-test
-
-[ laptop ] [
-    "laptop" get tuple-layout
-    dup layout-echelon swap
-    layout-superclasses nth
-] unit-test
-
-[ "TUPLE: laptop < computer battery ;" ] [
-    [ \ laptop see ] with-string-writer string-lines second
-] unit-test
-
-[ { tuple computer laptop } ] [ laptop superclasses ] unit-test
-
-TUPLE: server < computer rackmount ;
-C: <server> server
-
-[ t ] [ server tuple-class? ] unit-test
-[ t ] [ server tuple class< ] unit-test
-[ t ] [ server computer class< ] unit-test
-[ t ] [ server computer classes-intersect? ] unit-test
-
-[ ] [ "PowerPC" 64 "1U" <server> "server" set ] unit-test
-[ t ] [ "server" get server? ] unit-test
-[ t ] [ "server" get computer? ] unit-test
-[ t ] [ "server" get tuple? ] unit-test
-
-[ "PowerPC" ] [ "server" get cpu>> ] unit-test
-[ 64 ] [ "server" get ram>> ] unit-test
-[ "1U" ] [ "server" get rackmount>> ] unit-test
-
-[ f ] [ "server" get laptop? ] unit-test
-[ f ] [ "laptop" get server? ] unit-test
-
-[ f ] [ server laptop class< ] unit-test
-[ f ] [ laptop server class< ] unit-test
-[ f ] [ laptop server classes-intersect? ] unit-test
-
-[ f ] [ 1 2 <computer> laptop? ] unit-test
-[ f ] [ \ + server? ] unit-test
-
-[ "TUPLE: server < computer rackmount ;" ] [
-    [ \ server see ] with-string-writer string-lines second
-] unit-test
-
-[
-    "IN: tuples.tests TUPLE: bad-superclass < word ;" eval
-] must-fail
-
-! Reshaping with inheritance
-TUPLE: electronic-device ;
-
-[ ] [ "IN: tuples.tests TUPLE: computer < electronic-device ;" eval ] unit-test
-
-[ f ] [ electronic-device laptop class< ] unit-test
-[ t ] [ server electronic-device class< ] unit-test
-[ t ] [ laptop server class-or electronic-device class< ] unit-test
-
-[ t ] [ "laptop" get electronic-device? ] unit-test
-[ t ] [ "laptop" get computer? ] unit-test
-[ t ] [ "laptop" get laptop? ] unit-test
-[ f ] [ "laptop" get server? ] unit-test
-
-[ t ] [ "server" get electronic-device? ] unit-test
-[ t ] [ "server" get computer? ] unit-test
-[ f ] [ "server" get laptop? ] unit-test
-[ t ] [ "server" get server? ] unit-test
-
-[ ] [ "IN: tuples.tests TUPLE: computer ;" eval ] unit-test
-
-[ f ] [ "laptop" get electronic-device? ] unit-test
-[ t ] [ "laptop" get computer? ] unit-test
-
-! Hardcore unit tests
-USE: threads
-
-\ thread slot-names "slot-names" set
-
-[ ] [
-    [
-        \ thread tuple { "xxx" } "slot-names" get append
-        define-tuple-class
-    ] with-compilation-unit
-
-    [ 1337 sleep ] "Test" spawn drop
-
-    [
-        \ thread tuple "slot-names" get
-        define-tuple-class
-    ] with-compilation-unit
-] unit-test
-
-USE: vocabs
-
-\ vocab slot-names "slot-names" set
-
-[ ] [
-    [
-        \ vocab tuple { "xxx" } "slot-names" get append
-        define-tuple-class
-    ] with-compilation-unit
-
-    all-words drop
-
-    [
-        \ vocab tuple "slot-names" get
-        define-tuple-class
-    ] with-compilation-unit
-] unit-test
diff --git a/core/tuples/tuples.factor b/core/tuples/tuples.factor
deleted file mode 100755 (executable)
index f4ab215..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-! Copyright (C) 2005, 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: arrays definitions hashtables kernel
-kernel.private math namespaces sequences sequences.private
-strings vectors words quotations memory combinators generic
-classes classes.private slots.deprecated slots.private slots
-compiler.units math.private accessors ;
-IN: tuples
-
-M: tuple delegate 2 slot ;
-
-M: tuple set-delegate 2 set-slot ;
-
-M: tuple class 1 slot 2 slot { word } declare ;
-
-ERROR: no-tuple-class class ;
-
-<PRIVATE
-
-GENERIC: tuple-layout ( object -- layout )
-
-M: class tuple-layout "layout" word-prop ;
-
-M: tuple tuple-layout 1 slot ;
-
-: tuple-size tuple-layout layout-size ; inline
-
-PRIVATE>
-
-: check-tuple ( class -- )
-    dup tuple-class?
-    [ drop ] [ no-tuple-class ] if ;
-
-: tuple>array ( tuple -- array )
-    dup tuple-layout
-    [ layout-size swap [ array-nth ] curry map ] keep
-    layout-class add* ;
-
-: >tuple ( seq -- tuple )
-    dup first tuple-layout <tuple> [
-        >r 1 tail-slice dup length r>
-        [ tuple-size min ] keep
-        [ set-array-nth ] curry
-        2each
-    ] keep ;
-
-: slot-names ( class -- seq )
-    "slots" word-prop [ name>> ] map ;
-
-<PRIVATE
-
-: tuple= ( tuple1 tuple2 -- ? )
-    over tuple-layout over tuple-layout eq? [
-        dup tuple-size -rot
-        [ >r over r> array-nth >r array-nth r> = ] 2curry
-        all-integers?
-    ] [
-        2drop f
-    ] if ;
-
-! Predicate generation. We optimize at the expense of simplicity
-
-: (tuple-predicate-quot) ( class -- quot )
-    #! 4 slot == layout-superclasses
-    #! 5 slot == layout-echelon
-    [
-        [ 1 slot dup 5 slot ] %
-        dup tuple-layout layout-echelon ,
-        [ fixnum>= ] %
-        [
-            dup tuple-layout layout-echelon ,
-            [ swap 4 slot array-nth ] %
-            literalize ,
-            [ eq? ] %
-        ] [ ] make ,
-        [ drop f ] ,
-        \ if ,
-    ] [ ] make ;
-
-: tuple-predicate-quot ( class -- quot )
-    [
-        [ dup tuple? ] %
-        (tuple-predicate-quot) ,
-        [ drop f ] ,
-        \ if ,
-    ] [ ] make ;
-
-: define-tuple-predicate ( class -- )
-    dup tuple-predicate-quot define-predicate ;
-
-: superclass-size ( class -- n )
-    superclasses 1 head-slice*
-    [ slot-names length ] map sum ;
-
-: generate-tuple-slots ( class slots -- slots )
-    over superclass-size 2 + simple-slots ;
-
-: define-tuple-slots ( class slots -- )
-    dupd generate-tuple-slots
-    [ "slots" set-word-prop ]
-    [ define-accessors ]
-    [ define-slots ] 2tri ;
-
-: make-tuple-layout ( class -- layout )
-    [ ]
-    [ [ superclass-size ] [ "slots" word-prop length ] bi + ]
-    [ superclasses dup length 1- ] tri
-    <tuple-layout> ;
-
-: define-tuple-layout ( class -- )
-    dup make-tuple-layout "layout" set-word-prop ;
-
-: removed-slots ( class newslots -- seq )
-    swap slot-names seq-diff ;
-
-: forget-slots ( class slots -- )
-    dupd removed-slots [
-        [ reader-word forget-method ]
-        [ writer-word forget-method ] 2bi
-    ] with each ;
-
-: permutation ( seq1 seq2 -- permutation )
-    swap [ index ] curry map ;
-
-: reshape-tuple ( oldtuple permutation -- newtuple )
-    >r tuple>array 2 cut r>
-    [ [ swap ?nth ] [ drop f ] if* ] with map
-    append >tuple ;
-
-: reshape-tuples ( class superclass newslots -- )
-    nip
-    >r dup slot-names r> permutation
-    [
-        >r "predicate" word-prop instances dup
-        r> [ reshape-tuple ] curry map
-        become
-    ] 2curry after-compilation ;
-
-: define-new-tuple-class ( class superclass slots -- )
-    [ drop f tuple-class define-class ]
-    [ nip define-tuple-slots ] [
-        2drop
-        class-usages [
-            drop
-            [ define-tuple-layout ]
-            [ define-tuple-predicate ]
-            bi
-        ] assoc-each
-    ] 3tri ;
-
-: redefine-tuple-class ( class superclass slots -- )
-    [ reshape-tuples ]
-    [
-        nip
-        [ forget-slots ]
-        [ drop changed-word ]
-        [ drop redefined ]
-        2tri
-    ]
-    [ define-new-tuple-class ]
-    3tri ;
-
-: tuple-class-unchanged? ( class superclass slots -- ? )
-    rot tuck [ superclass = ] [ slot-names = ] 2bi* and ;
-
-PRIVATE>
-
-GENERIC# define-tuple-class 2 ( class superclass slots -- )
-
-M: word define-tuple-class
-    define-new-tuple-class ;
-
-M: tuple-class define-tuple-class
-    3dup tuple-class-unchanged?
-    [ 3dup redefine-tuple-class ] unless
-    3drop ;
-
-: define-error-class ( class superclass slots -- )
-    pick >r define-tuple-class r>
-    dup [ construct-boa throw ] curry define ;
-
-M: tuple clone
-    (clone) dup delegate clone over set-delegate ;
-
-M: tuple equal?
-    over tuple? [ tuple= ] [ 2drop f ] if ;
-
-: delegates ( obj -- seq )
-    [ dup ] [ [ delegate ] keep ] [ ] unfold nip ;
-
-: is? ( obj quot -- ? ) >r delegates r> contains? ; inline
-
-M: tuple hashcode*
-    [
-        dup tuple-size -rot 0 -rot [
-            swapd array-nth hashcode* bitxor
-        ] 2curry reduce
-    ] recursive-hashcode ;
-
-: tuple-slots ( tuple -- seq ) tuple>array 2 tail ;
-
-! Definition protocol
-M: tuple-class reset-class
-    { "metaclass" "superclass" "slots" "layout" } reset-props ;
-
-M: object get-slots ( obj slots -- ... )
-    [ execute ] with each ;
-
-M: object set-slots ( ... obj slots -- )
-    <reversed> get-slots ;
-
-M: object construct-empty ( class -- tuple )
-    tuple-layout <tuple> ;
-
-M: object construct ( ... slots class -- tuple )
-    construct-empty [ swap set-slots ] keep ;
-
-M: object construct-boa ( ... class -- tuple )
-    tuple-layout <tuple-boa> ;
index 85399ca9e71728efbd7ecd28fa9db568675c48a2..fd3b616b87c4f043304acc4a8b8df20a2a5b5790 100755 (executable)
@@ -2,7 +2,7 @@
 IN: vocabs.loader.tests
 USING: vocabs.loader tools.test continuations vocabs math
 kernel arrays sequences namespaces io.streams.string
-parser source-files words assocs tuples definitions
+parser source-files words assocs classes.tuple definitions
 debugger compiler.units tools.vocabs ;
 
 ! This vocab should not exist, but just in case...
index 4d9933147b970885313121612958a78e69b1fed4..cef6b1994389e82a7db13e75b6baff8bb623836f 100755 (executable)
@@ -1,6 +1,7 @@
 USING: arrays generic assocs kernel math namespaces
 sequences tools.test words definitions parser quotations
-vocabs continuations tuples compiler.units io.streams.string ;
+vocabs continuations classes.tuple compiler.units
+io.streams.string ;
 IN: words.tests
 
 [ 4 ] [
index 19d89f67f0dc247026eb986493c5236fb70e9a95..987122f05cfbd3c4a4dc480ccda11fec99ef82ea 100644 (file)
@@ -1,6 +1,6 @@
 
 USING: kernel parser namespaces quotations arrays vectors strings
-       sequences assocs tuples math combinators ;
+       sequences assocs classes.tuple math combinators ;
 
 IN: bake
 
index 6d7007c54a32092aa069411399b61777bb1520f0..0a808f53bd8185a175495721e9bb04c67d2e78d7 100755 (executable)
@@ -2,8 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 
 USING: arrays kernel math math.functions namespaces sequences
-strings tuples system vocabs.loader calendar.backend threads
-accessors combinators locals ;
+strings system vocabs.loader calendar.backend threads
+accessors combinators locals classes.tuple ;
 IN: calendar
 
 TUPLE: timestamp year month day hour minute second gmt-offset ;
diff --git a/extra/classes/tuple/lib/authors.txt b/extra/classes/tuple/lib/authors.txt
new file mode 100644 (file)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/extra/classes/tuple/lib/lib-docs.factor b/extra/classes/tuple/lib/lib-docs.factor
new file mode 100644 (file)
index 0000000..20431da
--- /dev/null
@@ -0,0 +1,27 @@
+USING: help.syntax help.markup kernel prettyprint sequences ;
+IN: classes.tuple.lib
+
+HELP: >tuple<
+{ $values { "class" "a tuple class" } }
+{ $description "Explodes the tuple so that tuple slots are on the stack in the order listed in the tuple." }
+{ $example
+    "USING: kernel prettyprint classes.tuple.lib ;"
+    "TUPLE: foo a b c ;"
+    "1 2 3 \\ foo construct-boa \\ foo >tuple< .s"
+    "1\n2\n3"
+}
+{ $notes "Words using " { $snippet ">tuple<" } " may be compiled." }
+{ $see-also >tuple*< } ;
+
+HELP: >tuple*<
+{ $values { "class" "a tuple class" } }
+{ $description "Explodes the tuple so that tuple slots ending with '*' are on the stack in the order listed in the tuple." }
+{ $example
+    "USING: kernel prettyprint classes.tuple.lib ;"
+    "TUPLE: foo a bb* ccc dddd* ;"
+    "1 2 3 4 \\ foo construct-boa \\ foo >tuple*< .s"
+    "2\n4"
+}
+{ $notes "Words using " { $snippet ">tuple*<" } " may be compiled." }
+{ $see-also >tuple< } ;
+
diff --git a/extra/classes/tuple/lib/lib-tests.factor b/extra/classes/tuple/lib/lib-tests.factor
new file mode 100644 (file)
index 0000000..328f83d
--- /dev/null
@@ -0,0 +1,8 @@
+USING: kernel tools.test classes.tuple.lib ;
+IN: classes.tuple.lib.tests
+
+TUPLE: foo a b* c d* e f* ;
+
+[ 1 2 3 4 5 6 ] [ 1 2 3 4 5 6 \ foo construct-boa \ foo >tuple< ] unit-test
+[ 2 4 6 ] [ 1 2 3 4 5 6 \ foo construct-boa \ foo >tuple*< ] unit-test
+
diff --git a/extra/classes/tuple/lib/lib.factor b/extra/classes/tuple/lib/lib.factor
new file mode 100755 (executable)
index 0000000..38104a4
--- /dev/null
@@ -0,0 +1,17 @@
+! Copyright (C) 2007 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel macros sequences slots words mirrors ;
+IN: classes.tuple.lib
+
+: reader-slots ( seq -- quot )
+    [ slot-spec-reader ] map [ get-slots ] curry ;
+
+MACRO: >tuple< ( class -- )
+    all-slots 1 tail-slice reader-slots ;
+
+MACRO: >tuple*< ( class -- )
+    all-slots
+    [ slot-spec-name "*" tail? ] subset
+    reader-slots ;
+
+
index f9e946fc20b94eb41136430523771e72b1df1981..55e672ec806d13d8fd8834259e60c89e13b94068 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays assocs classes continuations kernel math
-namespaces sequences sequences.lib tuples words strings
+namespaces sequences sequences.lib classes.tuple words strings
 tools.walker accessors ;
 IN: db
 
index 1de4bdfb5a0126c241d2e1312060b250db0eb3e9..99dde992808fb7df45541cee32f56741caa7b661 100755 (executable)
@@ -1,4 +1,4 @@
-USING: kernel parser quotations tuples words
+USING: kernel parser quotations classes.tuple words
 namespaces.lib namespaces sequences arrays combinators
 prettyprint strings math.parser sequences.lib math symbols ;
 USE: tools.walker
index c81448865f9e0349e98a180702c2cfb19edf2b24..9b3185bcf2052e43c4b862e57b7548d408d125fe 100755 (executable)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien arrays assocs classes compiler db
 hashtables io.files kernel math math.parser namespaces
-prettyprint sequences strings tuples alien.c-types
+prettyprint sequences strings classes.tuple alien.c-types
 continuations db.sqlite.lib db.sqlite.ffi db.tuples
 words combinators.lib db.types combinators
 io namespaces.lib ;
index 00e8ed8b763f13a30308bb6042f5274edc5c5340..7fc059c9b31ba38dafdf59f54e410abb93c3c960 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays assocs classes db kernel namespaces
-tuples words sequences slots math
+classes.tuple words sequences slots math
 math.parser io prettyprint db.types continuations
 mirrors sequences.lib tools.walker combinators.lib ;
 IN: db.tuples
index 94a8d6f3921aaede181cfb49421138b207a2d79d..3c73a933e927e4a9cb858a894a66814b22849d9f 100755 (executable)
@@ -3,7 +3,7 @@
 USING: arrays assocs db kernel math math.parser
 sequences continuations sequences.deep sequences.lib
 words namespaces tools.walker slots slots.private classes
-mirrors tuples combinators calendar.format symbols
+mirrors classes.tuple combinators calendar.format symbols
 singleton ;
 IN: db.types
 
index bfbfe1b6ca3b59a15af325c9e907de03558ee39e..85d58e75728f9b4cdbc2b50a11592ef409572a51 100755 (executable)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2005, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: parser kernel namespaces sequences definitions io.files
-inspector continuations tuples tools.crossref tools.vocabs 
+inspector continuations tools.crossref tools.vocabs 
 io prettyprint source-files assocs vocabs vocabs.loader
-io.backend splitting ;
+io.backend splitting classes.tuple ;
 IN: editors
 
 TUPLE: no-edit-hook ;
index 9e4d02802b70d87f055c7729b014296a71ba4c53..4e8424f7a3340f6ce6f143050ec92821b29849fa 100755 (executable)
@@ -2,9 +2,9 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays io kernel namespaces parser prettyprint sequences
 words assocs definitions generic quotations effects slots
-continuations tuples debugger combinators vocabs help.stylesheet
-help.topics help.crossref help.markup sorting classes
-vocabs.loader ;
+continuations classes.tuple debugger combinators vocabs
+help.stylesheet help.topics help.crossref help.markup sorting
+classes vocabs.loader ;
 IN: help
 
 GENERIC: word-help* ( word -- content )
index 828ff8e5627bd4afa2d725c2ad2dd65c94a937df..bd95bf4407ea2ba9582099a09c3a7f186a78a8a3 100755 (executable)
@@ -1,10 +1,10 @@
 ! Copyright (C) 2008 Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
-USING: html.elements http.server.validators accessors
-namespaces kernel io math.parser assocs classes words tuples
-arrays sequences io.files http.server.templating.fhtml
-http.server.actions splitting mirrors hashtables
-fry continuations math ;
+USING: html.elements http.server.validators accessors namespaces
+kernel io math.parser assocs classes words classes.tuple arrays
+sequences io.files http.server.templating.fhtml
+http.server.actions splitting mirrors hashtables fry
+continuations math ;
 IN: http.server.components
 
 SYMBOL: components
index 308bf36bf4892f22c0177de24e3f4a6f953dc31b..36b2e907789a686aa6cb66583db3c8faacab3bb0 100755 (executable)
@@ -1,7 +1,8 @@
 USING: kernel words inspector slots quotations sequences assocs
 math arrays inference effects shuffle continuations debugger
-tuples namespaces vectors bit-arrays byte-arrays strings sbufs
-math.functions macros sequences.private combinators mirrors ;
+classes.tuple namespaces vectors bit-arrays byte-arrays strings
+sbufs math.functions macros sequences.private combinators
+mirrors ;
 IN: inverse
 
 TUPLE: fail ;
index d2348fd4b0729946bb1428f0da88b89f088ecd26..259173fec4ea8d1285b6531ebf468980b2d190b1 100755 (executable)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2008 Daniel Ehrenberg
 ! See http://factorcode.org/license.txt for BSD license.
 USING: math.parser arrays io.encodings sequences kernel assocs
-hashtables io.encodings.ascii generic parser tuples words io
-io.files splitting namespaces math compiler.units accessors ;
+hashtables io.encodings.ascii generic parser classes.tuple words
+io io.files splitting namespaces math compiler.units accessors ;
 IN: io.encodings.8-bit
 
 <PRIVATE
index ae69553b536b76ad8d408a80b9596ede4bd191c7..ee9978f2c89a7bc8a106c79a30acd8eb028bdb8a 100755 (executable)
@@ -92,14 +92,6 @@ HELP: unless-eof
 { $values { "port" input-port } { "quot" "a quotation with stack effect " { $snippet "( port -- value )" } } { "value" object } }
 { $description "If the port has reached end of file, outputs " { $link f } ", otherwise applies the quotation to the port." } ;
 
-HELP: read-until-step
-{ $values { "separators" "a sequence of bytes" } { "port" input-port } { "byte-array/f" "a byte array or " { $link f } } { "separator/f" "a byte or " { $link f } } }
-{ $description "If the port has reached end of file, outputs " { $link f } { $link f } ", otherwise scans the buffer for a separator and outputs a string up to but not including the separator." } ;
-
-HELP: read-until-loop
-{ $values { "seps" "a sequence of bytes" } { "port" input-port } { "accum" byte-vector } { "separator/f" "a byte or " { $link f } } }
-{ $description "Accumulates data in the byte vector, calling " { $link (wait-to-read) } " as many times as necessary, until either an occurrence of a separator is read, or end of file is reached." } ;
-
 HELP: can-write?
 { $values { "len" "a positive integer" } { "writer" output-port } { "?" "a boolean" } }
 { $description "Tests if the port's output buffer can accomodate " { $snippet "len" } " bytes. If the buffer is empty, this always outputs " { $link t } ", since in that case the buffer will be grown automatically." } ;
index 10e55ed5f2ba77a8965c713d494f802c5717b2da..dcd13895b2b1831c0519250f869c05f1d69d3fd8 100755 (executable)
@@ -1,7 +1,7 @@
 USING: alien alien.c-types arrays assocs combinators
 continuations destructors io io.backend io.nonblocking
 io.windows libc kernel math namespaces sequences
-threads tuples.lib windows windows.errors
+threads classes.tuple.lib windows windows.errors
 windows.kernel32 strings splitting io.files qualified ascii
 combinators.lib ;
 QUALIFIED: windows.winsock
index a63a533ba12c6b27a30a0598ea245016254f1538..85bb34b2251afcc3eda3ed2a49922734905beae8 100755 (executable)
@@ -2,7 +2,7 @@ USING: alien alien.accessors alien.c-types byte-arrays
 continuations destructors io.nonblocking io.timeouts io.sockets
 io.sockets.impl io namespaces io.streams.duplex io.windows
 io.windows.nt.backend windows.winsock kernel libc math sequences
-threads tuples.lib ;
+threads classes.tuple.lib ;
 IN: io.windows.nt.sockets
 
 : malloc-int ( object -- object )
index 110e9b843c1d0f4396b805ac0854bb791c4f8151..f847bbff68882b245084256b5c51644ba18d984e 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2006 Chris Double.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel io.streams.string io strings splitting sequences math 
-       math.parser assocs tuples classes words namespaces 
+       math.parser assocs classes.tuple classes words namespaces 
        hashtables ;
 IN: json.writer
 
index 722c330a328fad2a3e7f280076ea11ba9e88b8de..fef925431de9a85ddd75c9a36f861b3f4e1eacf1 100755 (executable)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 !
 ! Based on pattern matching code from Paul Graham's book 'On Lisp'.
-USING: parser kernel words namespaces sequences tuples
+USING: parser kernel words namespaces sequences classes.tuple
 combinators macros assocs math ;
 IN: match
 
index d514a539aa580f77d2af52beec81e01f17e7874a..8cccb1c634d4c7404b822dbed6f41a9c76b23b97 100755 (executable)
@@ -1,4 +1,4 @@
-USING: help.syntax help.markup kernel math classes tuples
+USING: help.syntax help.markup kernel math classes classes.tuple
 calendar ;
 IN: models
 
index ec3df6ebee980e5f2607a8245312c3ea35a72a5c..2865b1fd6c1dc2087056b3dd4978e39ed2012353 100755 (executable)
@@ -7,12 +7,12 @@
 ! See http://factorcode.org/license.txt for BSD license.
 !
 USING: namespaces sequences kernel math io math.functions
-io.binary strings classes words sbufs tuples arrays vectors
-byte-arrays bit-arrays quotations hashtables assocs help.syntax
-help.markup float-arrays splitting io.streams.byte-array
-io.encodings.string io.encodings.utf8 io.encodings.binary
-combinators accessors locals prettyprint compiler.units
-sequences.private tuples.private ;
+io.binary strings classes words sbufs classes.tuple arrays
+vectors byte-arrays bit-arrays quotations hashtables assocs
+help.syntax help.markup float-arrays splitting
+io.streams.byte-array io.encodings.string io.encodings.utf8
+io.encodings.binary combinators accessors locals prettyprint
+compiler.units sequences.private classes.tuple.private ;
 IN: serialize
 
 ! Variable holding a assoc of objects already serialized
index 9983db7d00053432803f7ad9bd172ba126f1d3be..782f244c6874d9560755f5b0787461a45dc6738a 100755 (executable)
@@ -1,5 +1,5 @@
 IN: tools.disassembler.tests\r
-USING: math tuples prettyprint.backend tools.disassembler\r
+USING: math classes.tuple prettyprint.backend tools.disassembler\r
 tools.test strings ;\r
 \r
 [ ] [ \ + disassemble ] unit-test\r
index 061deec6ecf5fba82a70476fc173df88e3b519b9..b9593af23918db273b529355092bf8db36db2cbe 100644 (file)
@@ -1,6 +1,7 @@
 ! Copyright (C) 2007 Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: splitting tuples classes math kernel sequences arrays ;
+USING: splitting classes.tuple classes math kernel sequences
+arrays ;
 IN: tuple-arrays
 
 TUPLE: tuple-array example ;
diff --git a/extra/tuples/lib/authors.txt b/extra/tuples/lib/authors.txt
deleted file mode 100644 (file)
index 7c1b2f2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Doug Coleman
diff --git a/extra/tuples/lib/lib-docs.factor b/extra/tuples/lib/lib-docs.factor
deleted file mode 100644 (file)
index 75df155..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-USING: help.syntax help.markup kernel prettyprint sequences ;
-IN: tuples.lib
-
-HELP: >tuple<
-{ $values { "class" "a tuple class" } }
-{ $description "Explodes the tuple so that tuple slots are on the stack in the order listed in the tuple." }
-{ $example
-    "USING: kernel prettyprint tuples.lib ;"
-    "TUPLE: foo a b c ;"
-    "1 2 3 \\ foo construct-boa \\ foo >tuple< .s"
-    "1\n2\n3"
-}
-{ $notes "Words using " { $snippet ">tuple<" } " may be compiled." }
-{ $see-also >tuple*< } ;
-
-HELP: >tuple*<
-{ $values { "class" "a tuple class" } }
-{ $description "Explodes the tuple so that tuple slots ending with '*' are on the stack in the order listed in the tuple." }
-{ $example
-    "USING: kernel prettyprint tuples.lib ;"
-    "TUPLE: foo a bb* ccc dddd* ;"
-    "1 2 3 4 \\ foo construct-boa \\ foo >tuple*< .s"
-    "2\n4"
-}
-{ $notes "Words using " { $snippet ">tuple*<" } " may be compiled." }
-{ $see-also >tuple< } ;
-
diff --git a/extra/tuples/lib/lib-tests.factor b/extra/tuples/lib/lib-tests.factor
deleted file mode 100644 (file)
index 5d90f25..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-USING: kernel tools.test tuples.lib ;
-IN: tuples.lib.tests
-
-TUPLE: foo a b* c d* e f* ;
-
-[ 1 2 3 4 5 6 ] [ 1 2 3 4 5 6 \ foo construct-boa \ foo >tuple< ] unit-test
-[ 2 4 6 ] [ 1 2 3 4 5 6 \ foo construct-boa \ foo >tuple*< ] unit-test
-
diff --git a/extra/tuples/lib/lib.factor b/extra/tuples/lib/lib.factor
deleted file mode 100755 (executable)
index 4c007c8..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-! Copyright (C) 2007 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: kernel macros sequences slots words mirrors ;
-IN: tuples.lib
-
-: reader-slots ( seq -- quot )
-    [ slot-spec-reader ] map [ get-slots ] curry ;
-
-MACRO: >tuple< ( class -- )
-    all-slots 1 tail-slice reader-slots ;
-
-MACRO: >tuple*< ( class -- )
-    all-slots
-    [ slot-spec-name "*" tail? ] subset
-    reader-slots ;
-
-
index defd5aa38ab44ec27a84e8352f6b32a4269a993a..7e649b7ff7969e6088bb427720b5a17435f772b9 100755 (executable)
@@ -4,8 +4,8 @@ USING: arrays ui.commands ui.gadgets ui.gadgets.borders
 ui.gadgets.labels ui.gadgets.theme
 ui.gadgets.tracks ui.gadgets.packs ui.gadgets.worlds ui.gestures
 ui.render kernel math models namespaces sequences strings
-quotations assocs combinators classes colors tuples opengl
-math.vectors ;
+quotations assocs combinators classes colors classes.tuple
+opengl math.vectors ;
 IN: ui.gadgets.buttons
 
 TUPLE: button pressed? selected? quot ;
index a1fb95cdbff84df6b5c6a6e1ade5058952321fb9..15df44fda4fdf0a5834ac8ddd6359c8ad4f1c549 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: ui.backend ui.gadgets ui.gadgets.theme ui.gadgets.lib
 ui.gadgets.worlds ui.render opengl opengl.gl kernel namespaces
-tuples colors ;
+classes.tuple colors ;
 IN: ui.gadgets.canvas
 
 TUPLE: canvas dlist ;
index 6005b35cb932cd967d3c49f36d54d23e3fa8e9ca..c593358841c5698067a21c03cdc55d1d0150dbaf 100755 (executable)
@@ -1,5 +1,5 @@
 USING: help.syntax help.markup ui.gadgets kernel arrays
-quotations tuples ui.gadgets.grids ;
+quotations classes.tuple ui.gadgets.grids ;
 IN: ui.gadgets.frames
 
 : $ui-frame-constant ( element -- )
index 30f6a26d008909ebe455a262fabcd5e44ae07e38..018d1f1f861d3e959ecb160374dba1d6b6233f5e 100755 (executable)
@@ -1,5 +1,5 @@
 USING: help.markup help.syntax opengl kernel strings
-tuples classes quotations models ;
+classes.tuple classes quotations models ;
 IN: ui.gadgets
 
 HELP: rect
index 0231aef4d03c424fc84dd52305c9e21a83353286..d3f4339a87d0bacbdc9d782fd9796f82edb52f8c 100755 (executable)
@@ -4,7 +4,8 @@ USING: arrays ui.gadgets.buttons ui.gadgets.borders
 ui.gadgets.labels ui.gadgets.panes ui.gadgets.scrollers
 ui.gadgets.tracks ui.gadgets.theme ui.gadgets.frames
 ui.gadgets.grids io kernel math models namespaces prettyprint
-sequences sequences words tuples ui.gadgets ui.render colors ;
+sequences sequences words classes.tuple ui.gadgets ui.render
+colors ;
 IN: ui.gadgets.labelled
 
 TUPLE: labelled-gadget content ;
index 3bac7969c506789d6271fb8440fd6968f845230f..9213c3886ff060d49e288d43a8f093784e9bded8 100755 (executable)
@@ -4,7 +4,7 @@ USING: ui.commands ui.gestures ui.render ui.gadgets
 ui.gadgets.labels ui.gadgets.scrollers
 kernel sequences models opengl math namespaces
 ui.gadgets.presentations ui.gadgets.viewports ui.gadgets.packs
-math.vectors tuples ;
+math.vectors classes.tuple ;
 IN: ui.gadgets.lists
 
 TUPLE: list index presenter color hook ;
index 55404c0eceeb11833bbb2c21c10bed08cc4d07e6..e80e5b58894937f0fc97be31512533bfbe01a792 100755 (executable)
@@ -1,5 +1,5 @@
-USING: ui.gadgets help.markup help.syntax generic kernel tuples
-quotations ;
+USING: ui.gadgets help.markup help.syntax generic kernel
+classes.tuple quotations ;
 IN: ui.gadgets.packs
 
 HELP: pack
index dde312b34dcf10a6180b64f18f34561b266dfd86..52c5ca8a026de990685befd4cb3431b8143e396d 100755 (executable)
@@ -8,7 +8,7 @@ hashtables io kernel namespaces sequences io.styles strings
 quotations math opengl combinators math.vectors
 io.streams.duplex sorting splitting io.streams.nested assocs
 ui.gadgets.presentations ui.gadgets.slots ui.gadgets.grids
-ui.gadgets.grid-lines tuples models continuations ;
+ui.gadgets.grid-lines classes.tuple models continuations ;
 IN: ui.gadgets.panes
 
 TUPLE: pane output current prototype scrolls?
index 46f274d53a6f7977f11912cf63ff43289f5411f0..55ba2604e859b1e5113fd3683018bf0ed9d6f80e 100644 (file)
@@ -1,7 +1,7 @@
 IN: ui.gadgets.presentations.tests
 USING: math ui.gadgets.presentations ui.gadgets tools.test
 prettyprint ui.gadgets.buttons io io.streams.string kernel
-tuples ;
+classes.tuple ;
 
 [ t ] [
     "Hi" \ + <presentation> [ gadget? ] is?
index 7966f4e206af04edcf8b138e37ff673cf206caad..99bd1be876a2f4b3d865ea919050afd6c06f666d 100755 (executable)
@@ -4,7 +4,7 @@ USING: arrays ui.gadgets
 ui.gadgets.viewports ui.gadgets.frames ui.gadgets.grids
 ui.gadgets.theme ui.gadgets.sliders ui.gestures kernel math
 namespaces sequences models combinators math.vectors
-tuples ;
+classes.tuple ;
 IN: ui.gadgets.scrollers
 
 TUPLE: scroller viewport x y follows ;
index 967e8a29a107b3a086ea0f4ed754475e62f4d365..f10996135d230c6dd01ec3b305c7cd11aa153439 100755 (executable)
@@ -1,5 +1,5 @@
 USING: ui.gadgets.packs help.markup help.syntax ui.gadgets
-arrays kernel quotations tuples ;
+arrays kernel quotations classes.tuple ;
 IN: ui.gadgets.tracks
 
 HELP: track
index 574b71c44dd66164828dcd3897e8a727d18d75ac..412a61bcb55a690294e58cf8bd12566d35eb0ddc 100755 (executable)
@@ -2,7 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays assocs kernel math models namespaces
 sequences words strings system hashtables math.parser
-math.vectors tuples classes ui.gadgets combinators.lib boxes
+math.vectors classes.tuple classes ui.gadgets combinators.lib
+boxes
 calendar alarms symbols ;
 IN: ui.gestures
 
index 9e43460aa9bc26392151659021e18e0a9109a2a8..06fc3c87a0c2778254ba87d76d121dac0a6761b6 100755 (executable)
@@ -4,7 +4,7 @@ USING: arrays assocs combinators continuations documents
  hashtables io io.styles kernel math
 math.vectors models namespaces parser prettyprint quotations
 sequences sequences.lib strings threads listener
-tuples ui.commands ui.gadgets ui.gadgets.editors
+classes.tuple ui.commands ui.gadgets ui.gadgets.editors
 ui.gadgets.presentations ui.gadgets.worlds ui.gestures
 definitions boxes calendar concurrency.flags ui.tools.workspace ;
 IN: ui.tools.interactor
index 45ac64539262e6b684cf2bbcd86b143605d5d2c4..23697bbf3facb299834b30afcfdf713a2bb4f6bc 100755 (executable)
@@ -4,7 +4,7 @@ USING: assocs ui.tools.interactor ui.tools.listener
 ui.tools.workspace help help.topics io.files io.styles kernel
 models namespaces prettyprint quotations sequences sorting
 source-files definitions strings tools.completion tools.crossref
-tuples ui.commands ui.gadgets ui.gadgets.editors
+classes.tuple ui.commands ui.gadgets ui.gadgets.editors
 ui.gadgets.lists ui.gadgets.scrollers ui.gadgets.tracks
 ui.gestures ui.operations vocabs words vocabs.loader
 tools.vocabs unicode.case calendar ui ;
index 158a48a1c098d0a275918ba3978779fd94584544..eaf87acaceb71d323f85f02f9b23c0e0c36810c7 100755 (executable)
@@ -5,7 +5,7 @@ ui.backend ui.clipboards ui.gadgets.worlds assocs kernel math
 namespaces opengl sequences strings x11.xlib x11.events x11.xim
 x11.glx x11.clipboard x11.constants x11.windows io.encodings.string
 io.encodings.utf8 combinators debugger system command-line
-ui.render math.vectors tuples opengl.gl threads ;
+ui.render math.vectors classes.tuple opengl.gl threads ;
 IN: ui.x11
 
 TUPLE: x11-ui-backend ;