]> gitweb.factorcode.org Git - factor.git/commitdiff
generic words are more flexible, sequences cleaned up
authorSlava Pestov <slava@factorcode.org>
Sat, 14 May 2005 21:18:45 +0000 (21:18 +0000)
committerSlava Pestov <slava@factorcode.org>
Sat, 14 May 2005 21:18:45 +0000 (21:18 +0000)
59 files changed:
CHANGES.txt
TODO.FACTOR.txt
contrib/cont-responder/eval-responder.factor
contrib/cont-responder/todo-example.factor
examples/lcd.factor
examples/timesheet.factor
library/alien/aliens.factor
library/bootstrap/image.factor
library/collections/arrays.factor
library/collections/assoc.factor
library/collections/cons.factor
library/collections/hashtables.factor
library/collections/lists.factor
library/collections/sbuf.factor
library/collections/sequences-epilogue.factor
library/collections/sequences.factor
library/collections/strings.factor
library/collections/vectors.factor
library/combinators.factor
library/compiler/generator.factor
library/compiler/linearizer.factor
library/generic/builtin.factor
library/generic/generic.factor
library/generic/slots.factor
library/generic/tuple.factor
library/httpd/html.factor
library/httpd/http-common.factor
library/inference/branches.factor
library/inference/conditions.factor
library/kernel.factor
library/math/complex.factor
library/math/float.factor
library/math/integer.factor
library/math/math.factor
library/math/matrices.factor
library/math/ratio.factor
library/sdl/sdl-keyboard.factor
library/syntax/generic.factor
library/syntax/parse-numbers.factor
library/syntax/parse-syntax.factor
library/syntax/prettyprint.factor
library/syntax/see.factor
library/syntax/unparser.factor
library/test/generic.factor
library/test/strings.factor
library/test/vectors.factor
library/tools/word-tools.factor
library/ui/buttons.factor
library/ui/checkboxes.factor
library/ui/frames.factor
library/ui/gadgets.factor
library/ui/gestures.factor
library/ui/labels.factor
library/ui/layouts.factor
library/ui/paint.factor
library/ui/stacks.factor
library/ui/text.factor
library/ui/world.factor
library/words.factor

index 7ae97b0ba874e49ba118b4d71ac5cb40ab0ace79..72d8a08bb5b6024a8793b22d9a67c84055d1012d 100644 (file)
@@ -1,8 +1,11 @@
 Factor 0.75:
 ------------
 
-The SO_OOBINLINE socket flag is now set. In 0.74, sending out-of-band
-data could fill up the buffer and cause a denial-of-service attack.
+New generational garbage collector. There are two command line switches
+for controlling it:
+
+ +Yn   Size of 2 youngest generations, megabytes
+ +An   Size of tenured and semi-spaces, megabytes
 
 The alien interface now supports "float" and "double" types.
 
@@ -10,6 +13,26 @@ Defining a predicate subclass of tuple is supported now. Note that
 unions and complements over tuples are still not supported. Also,
 predicate subclasses of concrete tuple classes are not supported either.
 
+The seq-each and seq-map words have been renamed to each and map, and
+now work with lists. The each and map words in the lists vocabulary have
+been removed; use the new generic equivalents instead.
+
+The SO_OOBINLINE socket flag is now set. In 0.74, sending out-of-band
+data could fill up the buffer and cause a denial-of-service attack.
+
+Generic words can now dispatch on stack elements other than the top one;
+define your generic like this to dispatch on the second element:
+
+ G: foo [ over ] [ type ] ;
+
+Or this for the third:
+
+ G: foo [ pick ] [ type ] ;
+
+Note that GENERIC: foo is the same as
+
+ G: foo [ dup ] [ type ] ;
+
 Factor 0.74:
 ------------
 
index db8266ccce0a6fb31d5f5672c73bd423a9b49e69..a01eba61d5ccea0018c72d11f57c55df453a33b3 100644 (file)
@@ -6,7 +6,7 @@
 <magnus--> http://www.caddr.com/macho/archives/sbcl-devel/2005-3/4764.html\r
 <magnus--> http://clozure.com/cgi-bin/viewcvs.cgi/ccl/lisp-kernel/lisp-exceptions.c?rev=1.9&content-type=text/vnd.viewcvs-markup\r
 \r
-\r
+- investigate if COPYING_GEN needs a fix\r
 - alien-global type wrong\r
 - simplifier:\r
   - dead loads not optimized out\r
@@ -22,8 +22,6 @@
 - sleep word\r
 - update docs\r
 - redo new compiler backend for PowerPC\r
-- type predicates: : foo? type 7 eq? ;\r
-- remove 'not' word, and move t?/f? to kernel\r
 \r
 - plugin: supportsBackspace\r
 - if external factor is down, don't add tons of random shit to the       \r
 - nappend: instead of using push, enlarge the sequence with set-length\r
   then add set the elements with set-nth\r
 - faster sequence operations\r
-- generic each some? all? memq? all=?  index? subseq? map\r
+- generic some? all? memq? all=?  index? subseq?\r
 - index and index* are very slow with lists\r
 - unsafe-sbuf>string\r
 - generic subseq\r
-- GENERIC: map\r
-  - list impl same as now\r
 - code walker & exceptions\r
 - if two tasks write to a unix stream, the buffer can overflow\r
 - rename prettyprint to pprint\r
index 92397e6c9a3bdcd79bf55e4deec1bbbcc5b81155..ad92fafe36c07d5e93e2fdd17a380d5f81a89abc 100644 (file)
@@ -73,7 +73,7 @@ USE: sequences
 : escape-quotes ( string -- string )
   #! Replace occurrences of single quotes with
   #! backslash quote.
-  [ dup [ [[ CHAR: ' "\\'" ]] [[ CHAR: " "\\\"" ]] ] assoc dup rot ? ] seq-map ;
+  [ dup [ [[ CHAR: ' "\\'" ]] [[ CHAR: " "\\\"" ]] ] assoc dup rot ? ] map ;
  
 : make-eval-javascript ( string -- string )
   #! Give a string return some javascript that when
index cf1462e8bfd93adeca052f8b0de76e571d03f199..cafaa483ac90b640b276d54f76a8121c5814b20c 100644 (file)
@@ -209,7 +209,7 @@ USE: sequences
     ] [ 
       drop CHAR: _ 
     ] ifte 
-  ] seq-map ;
+  ] map ;
 
 : is-valid-username? ( username -- bool )
   #! Return true if the username parses correctly
index f21af2b9a53a59edfadcd474239f3405b5c6da3e..21a5598300a67daa7ecb0857e53e8aef260f1610 100644 (file)
@@ -8,7 +8,7 @@ USING: sequences kernel math stdio strings ;
     } nth >r 4 * dup 4 + r> substring ;
 
 : lcd-row ( num row -- )
-    swap [ CHAR: 0 - over lcd-digit write ] seq-each drop ;
+    swap [ CHAR: 0 - over lcd-digit write ] each drop ;
 
 : lcd ( num -- str )
     3 [ 2dup lcd-row terpri ] repeat drop ;
index 094fbcbe143e5281faf03afed9ee49e7754dd91d..cbf1fb016e158599968888e1c38ad08babb86e4b 100644 (file)
@@ -36,7 +36,7 @@ strings unparser vectors ;
 
 : print-timesheet ( timesheet -- )
     "TIMESHEET:" print
-    [ uncons print-entry ] seq-each ;
+    [ uncons print-entry ] each ;
 
 ! Displaying a menu
 
index 32631d4c5ff3cb62d8aec3e77e35a509034c43fb..80b4247e46e65383c14d887cd50785d90e7d6d01 100644 (file)
@@ -3,10 +3,14 @@
 IN: alien
 USING: hashtables kernel lists math namespaces parser stdio ;
 
-BUILTIN: dll   15 [ 1 "dll-path" f ] ;
-BUILTIN: alien 16 ;
-BUILTIN: byte-array 19 ;
-BUILTIN: displaced-alien 20 ;
+DEFER: dll?
+BUILTIN: dll 15 dll? [ 1 "dll-path" f ] ;
+DEFER: alien?
+BUILTIN: alien 16 alien? ;
+DEFER: byte-array?
+BUILTIN: byte-array 19 byte-array? ;
+DEFER: displaced-alien?
+BUILTIN: displaced-alien 20 displaced-alien? ;
 
 : NULL ( -- null )
     #! C null value.
index 915069957931805f25ddc217bfe54500ac5432bd..31445a8ce41eb3b9abd649862a35cfa7704bb5dc 100644 (file)
@@ -180,7 +180,7 @@ M: f ' ( obj -- ptr )
 : fixup-words ( -- )
     image get [
         dup word? [ fixup-word ] when
-    ] seq-map image set ;
+    ] map image set ;
 
 M: word ' ( word -- pointer )
     transfer-word dup pooled-object dup [ nip ] [ drop ] ifte ;
@@ -311,7 +311,7 @@ M: hashtable ' ( hashtable -- pointer )
     ] ifte ;
 
 : write-image ( image file -- )
-    <file-writer> [ [ write-word ] seq-each ] with-stream ;
+    <file-writer> [ [ write-word ] each ] with-stream ;
 
 : with-minimal-image ( quot -- image )
     [
index 30a58eab1a7e046842c10fba7b448c0962427337..e4e12a3f916a249533f8bccae62d45217976b194 100644 (file)
@@ -17,7 +17,8 @@ DEFER: repeat
 IN: kernel-internals
 USING: kernel math-internals sequences ;
 
-BUILTIN: array 8  ;
+DEFER: array?
+BUILTIN: array 8 array? ;
 
 : array-capacity ( a -- n ) 1 slot ; inline
 : array-nth ( n a -- obj ) swap 2 fixnum+ slot ; inline
index e9250d3400c8076e6eab1c8ead35a1dc269dee08..f4221056ba35dcd1dcc0f53b55b91b19e8080a8e 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2004, 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
-IN: lists USING: kernel ;
+IN: lists USING: kernel sequences ;
 
 ! An association list is a list of conses where the car of each
 ! cons is a key, and the cdr is a value. See the Factor
index 92bfbe397ea660bc2b1f9da46cd6ecb7ffd4af86..af86ca1b6eb37baed1218273989cfdd8e894645b 100644 (file)
@@ -6,7 +6,9 @@ IN: lists USING: generic kernel sequences ;
 ! else depends on, and is loaded early in bootstrap.
 ! lists.factor has everything else.
 
-BUILTIN: cons 2 [ 0 "car" f ] [ 1 "cdr" f ] ;
+DEFER: cons?
+BUILTIN: cons 2 cons? [ 0 "car" f ] [ 1 "cdr" f ] ;
+UNION: general-list f cons ;
 
 ! We borrow an idiom from Common Lisp. The car/cdr of an empty
 ! list is the empty list.
@@ -14,6 +16,7 @@ M: f car ;
 M: f cdr ;
 
 GENERIC: >list ( seq -- list )
+M: general-list >list ( list -- list ) ;
 
 : swons ( cdr car -- [[ car cdr ]] )
     #! Push a new cons cell. If the cdr is f or a proper list,
@@ -49,17 +52,11 @@ M: cons peek ( list -- last )
     #! Last element of a list.
     last car ;
 
-UNION: general-list f cons ;
-
 PREDICATE: general-list list ( list -- ? )
     #! Proper list test. A proper list is either f, or a cons
     #! cell whose cdr is a proper list.
     dup [ last cdr ] when not ;
 
-: with ( obj quot elt -- obj quot )
-    #! Utility word for each-with, map-with.
-    pick pick >r >r swap call r> r> ; inline
-
 : all? ( list pred -- ? )
     #! Push if the predicate returns true for each element of
     #! the list.
@@ -79,15 +76,13 @@ PREDICATE: general-list list ( list -- ? )
 : (each) ( list quot -- list quot )
     [ >r car r> call ] 2keep >r cdr r> ; inline
 
-: each ( list quot -- )
+M: general-list each ( list quot -- )
     #! Push each element of a proper list in turn, and apply a
     #! quotation with effect ( elt -- ) to each element.
-    over [ (each) each ] [ 2drop ] ifte ; inline
+    over [ (each) each ] [ 2drop ] ifte ;
 
-: each-with ( obj list quot -- )
-    #! Push each element of a proper list in turn, and apply a
-    #! quotation with effect ( obj elt -- ) to each element.
-    swap [ with ] each 2drop ; inline
+M: cons tree-each ( cons quot -- )
+    >r uncons r> tuck >r >r tree-each r> r> tree-each ;
 
 : subset ( list quot -- list )
     #! Applies a quotation with effect ( X -- ? ) to each
index 2ca2157561632bb1be8bfb36191433e2539ee218..0ce933485571907da914a721d91ac62e4648f047 100644 (file)
@@ -11,7 +11,8 @@ USING: generic kernel lists math sequences vectors ;
 
 ! We put hash-size in the hashtables vocabulary, and
 ! the other words in kernel-internals.
-BUILTIN: hashtable 10
+DEFER: hashtable?
+BUILTIN: hashtable 10 hashtable?
     [ 1 "hash-size" set-hash-size ]
     [ 2 hash-array set-hash-array ] ;
 
index 976000459be0ab57383d7ca3b831f65d44da7d94..85465f56b54e0f2e79b64da4db3bd212a9504467 100644 (file)
@@ -3,7 +3,8 @@
 IN: lists USING: errors generic kernel math sequences ;
 
 ! Sequence protocol
-M: general-list length 0 swap [ drop 1 + ] each ;
+M: f length drop 0 ;
+M: cons length cdr length 1 + ;
 
 M: f empty? drop t ;
 M: cons empty? drop f ;
@@ -65,17 +66,11 @@ M: general-list contains? ( obj list -- ? )
 M: general-list reverse ( list -- list )
     [ ] swap [ swons ] each ;
 
-: map ( list quot -- list )
+M: general-list map ( list quot -- list )
     #! Push each element of a proper list in turn, and collect
     #! return values of applying a quotation with effect
     #! ( X -- Y ) to each element into a new list.
-    over [ (each) rot >r map r> swons ] [ drop ] ifte ; inline
-
-: map-with ( obj list quot -- list )
-    #! Push each element of a proper list in turn, and collect
-    #! return values of applying a quotation with effect
-    #! ( obj elt -- obj ) to each element into a new list.
-    swap [ with rot ] map 2nip ; inline
+    over [ (each) rot >r map r> swons ] [ drop ] ifte ;
 
 : remove ( obj list -- list )
     #! Remove all occurrences of objects equal to this one from
index 744659151cf6de23935f7d0a0e21257a84286789..8c41dba9b6e75ba507d291970c9989871a08f8e6 100644 (file)
@@ -6,7 +6,8 @@ sequences ;
 
 M: string (grow) grow-string ;
 
-BUILTIN: sbuf 13
+DEFER: sbuf?
+BUILTIN: sbuf 13 sbuf?
     [ 1 length set-capacity ]
     [ 2 underlying set-underlying ] ;
 
index 5696ea3b79ba00326082c821996d66eec409e471..5aa737c8bbafb2a24f80e09f388d032ff5034302 100644 (file)
@@ -23,38 +23,18 @@ M: object empty? ( seq -- ? ) length 0 = ;
     ] ifte ;
 
 M: object >list ( seq -- list ) dup length 0 rot (>list) ;
-M: general-list >list ( list -- list ) ;
 
 : 2nth ( s s n -- x x ) tuck swap nth >r swap nth r> ;
 
 ! Combinators
-GENERIC: (seq-each) ( quot seq -- ) inline
+M: object each ( quot seq -- )
+    swap dup length [
+        [ swap nth swap call ] 3keep
+    ] repeat 2drop ;
 
-M: object (seq-each) ( quot seq -- )
-    dup length [ [ swap nth swap call ] 3keep ] repeat 2drop ;
+M: object tree-each call ;
 
-M: general-list (seq-each) ( quot seq -- )
-    swap each ;
-
-: seq-each ( seq quot -- ) swap (seq-each) ; inline
-
-: seq-each-with ( obj seq quot -- )
-    swap [ with ] seq-each 2drop ; inline
-
-GENERIC: (tree-each) ( quot obj -- ) inline
-
-M: object (tree-each) swap call ;
-
-M: cons (tree-each) [ car (tree-each) ] 2keep cdr (tree-each) ;
-
-M: f (tree-each) swap call ;
-
-M: sequence (tree-each) [ (tree-each) ] seq-each-with ;
-
-: tree-each swap (tree-each) ; inline
-
-: tree-each-with ( obj vector quot -- )
-    swap [ with ] tree-each 2drop ; inline
+M: sequence tree-each swap [ swap tree-each ] each-with ;
 
 : change-nth ( seq i quot -- )
     pick pick >r >r >r swap nth r> call r> r> swap set-nth ;
@@ -74,11 +54,8 @@ M: sequence (tree-each) [ (tree-each) ] seq-each-with ;
 : immutable ( seq quot -- seq | quot: seq -- )
     swap [ thaw ] keep >r dup >r swap call r> r> freeze ; inline
 
-: seq-map ( seq quot -- seq | quot: elt -- elt )
-    swap [ swap nmap ] immutable ; inline
-
-: seq-map-with ( obj list quot -- list )
-    swap [ with rot ] seq-map 2nip ; inline
+M: object map ( seq quot -- seq | quot: elt -- elt )
+    swap [ swap nmap ] immutable ;
 
 : (2nmap) ( seq1 seq2 i quot -- elt3 )
     pick pick >r >r >r 2nth r> call r> r> swap set-nth ; inline
@@ -89,8 +66,8 @@ M: sequence (tree-each) [ (tree-each) ] seq-each-with ;
         [ >r 3dup r> swap (2nmap) ] keep
     ] repeat 3drop ; inline
 
-: seq-2map ( seq1 seq2 quot -- seq | quot: elt1 elt2 -- elt3 )
-    swap [ swap 2nmap ] immutable ; inline
+M: object 2map ( seq1 seq2 quot -- seq | quot: elt1 elt2 -- elt3 )
+    swap [ swap 2nmap ] immutable ;
 
 ! Operations
 : index* ( obj i seq -- n )
@@ -113,7 +90,7 @@ M: object contains? ( obj seq -- ? ) index -1 > ;
 
 : nappend ( s1 s2 -- )
     #! Destructively append s2 to s1.
-    [ over push ] seq-each drop ;
+    [ over push ] each drop ;
 
 : append ( s1 s2 -- s1+s2 )
     #! Return a new sequence of the same type as s1.
@@ -126,7 +103,7 @@ M: object contains? ( obj seq -- ? ) index -1 > ;
 : concat ( seq -- seq )
     #! Append together a sequence of sequences.
     dup empty? [
-        unswons [ swap [ nappend ] seq-each-with ] immutable
+        unswons [ swap [ nappend ] each-with ] immutable
     ] unless ;
 
 M: object peek ( sequence -- element )
index 800a80c99d5674c8eb3db14727da5709830bccef..53c7ed77eeb57dafc7ed6e4e7547f47c0a22cda4 100644 (file)
@@ -22,6 +22,27 @@ GENERIC: reverse ( seq -- seq )
 GENERIC: peek ( seq -- elt )
 GENERIC: contains? ( elt seq -- ? )
 
+G: each ( seq quot -- | quot: elt -- )
+    [ over ] [ type ] ; inline
+
+: each-with ( obj seq quot -- | quot: obj elt -- )
+    swap [ with ] each 2drop ; inline
+
+G: tree-each ( obj quot -- | quot: elt -- )
+    [ over ] [ type ] ; inline
+
+: tree-each-with ( obj vector quot -- )
+    swap [ with ] tree-each 2drop ; inline
+
+G: map ( seq quot -- seq | quot: elt -- elt )
+    [ over ] [ type ] ; inline
+
+: map-with ( obj list quot -- list | quot: obj elt -- elt )
+    swap [ with rot ] map 2nip ; inline
+
+G: 2map ( seq seq quot -- seq | quot: elt elt -- elt )
+    [ over ] [ type ] ; inline
+
 DEFER: append ! remove this when sort is moved from lists to sequences
 
 ! Some low-level code used by vectors and string buffers.
index 8bfd7bf55c5f0ffd40208d2fa9ad294348029cf7..6b2853adce3cfda5bea79bade41ea9b2cd2d7e2f 100644 (file)
@@ -4,7 +4,8 @@ IN: strings
 USING: generic kernel kernel-internals lists math sequences ;
 
 ! Strings
-BUILTIN: string 12 [ 1 length f ] [ 2 hashcode f ] ;
+DEFER: string?
+BUILTIN: string 12 string? [ 1 length f ] [ 2 hashcode f ] ;
 
 M: string =
     over string? [
index 9c356524a135b574f8f88a2e65f85b6aac1c5c1c..d3d139ae962f234779e1ae35b9655ba71d32e49e 100644 (file)
@@ -4,7 +4,8 @@ IN: vectors
 USING: errors generic kernel kernel-internals lists math
 math-internals sequences ;
 
-BUILTIN: vector 11
+DEFER: vector?
+BUILTIN: vector 11 vector?
     [ 1 length set-capacity ]
     [ 2 underlying set-underlying ] ;
 
index 5456f51575261b71b87703320b47d90dbedc0056..afd71e8a7150c208e3dcf955d5bc2beaeecbc218 100644 (file)
@@ -55,3 +55,7 @@ IN: kernel
     #! the quotation is evaluated. Otherwise, the condition is
     #! popped off the stack.
     dupd [ drop ] ifte ; inline
+
+: with ( obj quot elt -- obj quot )
+    #! Utility word for each-with, map-with.
+    pick pick >r >r swap call r> r> ; inline
index d569cb67a8c4f01e74975bf084e28ccdaf91859a..ca72b221912b5e3ec879c34b0ad75d1ae8d5ff6d 100644 (file)
@@ -17,7 +17,7 @@ GENERIC: generate-node ( vop -- )
 
 : generate-reloc ( -- length )
     relocation-table get
-    dup [ compile-cell ] seq-each
+    dup [ compile-cell ] each
     length cell * ;
 
 : (generate) ( word linear -- )
index 4a5c799f5b2f277bed55de8f0be21bab87b865d7..c58a5015c7280a321a85af11ec8705afbd36ddf8 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2004, 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: compiler-frontend
-USING: compiler-backend inference kernel lists math namespaces
-words strings errors prettyprint kernel-internals ;
+USING: compiler-backend inference kernel kernel-internals lists
+math namespaces words strings errors prettyprint sequences ;
 
 : >linear ( node -- )
     #! Dataflow OPs have a linearizer word property. This
index 4f7f352e689fadf5a08fba24a6c01c90a5e9319b..97d1ddd5d681c7689abaafb1e5fbfb8afdcfda41 100644 (file)
@@ -24,29 +24,25 @@ builtin 50 "priority" set-word-prop
 ! All builtin types are equivalent in ordering
 builtin [ 2drop t ] "class<" set-word-prop
 
-: builtin-predicate ( type# symbol -- )
-    #! We call search here because we have to know if the symbol
-    #! is t or f, and cannot compare type numbers or symbol
-    #! identity during bootstrapping.
-    dup "f" [ "syntax" ] search = [
-        nip [ not ] "predicate" set-word-prop
-    ] [
-        dup "t" [ "syntax" ] search = [
-            nip [ ] "predicate" set-word-prop
-        ] [
-            dup predicate-word
-            [ rot [ swap type eq? ] cons define-compound ] keep
-            unit "predicate" set-word-prop
-        ] ifte
-    ] ifte ;
-
-: builtin-class ( symbol type# slotspec -- )
-    >r 2dup builtins get set-nth r>
-    >r swap
+: builtin-predicate ( class -- )
+    dup "predicate" word-prop car swap
+    [
+        \ type , "builtin-type" word-prop , \ eq? ,
+    ] make-list
+    define-compound ;
+
+: register-builtin ( class -- )
+    dup "builtin-type" word-prop builtins get set-nth ;
+
+: define-builtin ( symbol type# predicate slotspec -- )
+    >r >r >r
     dup intern-symbol
-    2dup builtin-predicate
-    [ swap "builtin-type" set-word-prop ] keep
-    dup builtin define-class r> define-slots ;
+    dup r> "builtin-type" set-word-prop
+    dup builtin define-class
+    dup r> unit "predicate" set-word-prop
+    dup builtin-predicate
+    dup r> define-slots
+    register-builtin ;
 
 : builtin-type ( n -- symbol ) builtins get nth ;
 
index 7f30fbf5758349624d68babc3c478b05d1fe2421..58e587a647ff7220943e3001bc2a90ff5a2f055f 100644 (file)
@@ -17,7 +17,8 @@ math-internals ;
 ! based on type, or some combination of type, predicate, or
 ! method map.
 ! - metaclass: a metaclass is a symbol with a handful of word
-! properties: "builtin-types" "priority"
+! properties: "builtin-supertypes" "priority" "add-method"
+! "class<"
 
 ! Metaclasses have priority -- this induces an order in which
 ! methods are added to the vtable.
@@ -57,9 +58,8 @@ math-internals ;
     ] unless* call ;
 
 : <empty-vtable> ( generic -- vtable )
-    unit num-types
-    [ drop dup [ car no-method ] cons ] vector-project
-    nip ;
+    [ literal, \ no-method , ] make-list
+    num-types swap <repeated> >vector ;
 
 : <vtable> ( generic -- vtable )
     dup <empty-vtable> over methods [
@@ -70,8 +70,12 @@ math-internals ;
 : make-generic ( word -- )
     #! (define-compound) is used to avoid resetting generic
     #! word properties.
-    dup <vtable> over "combination" word-prop cons
-    (define-compound) ;
+    [
+        dup "picker" word-prop %
+        dup "dispatcher" word-prop %
+        dup <vtable> ,
+        \ dispatch ,
+    ] make-list (define-compound) ;
 
 : define-method ( class generic definition -- )
     -rot
@@ -88,30 +92,25 @@ math-internals ;
      ] ifte ;
 
 ! Defining generic words
-: define-generic ( combination word -- )
-    #! Takes a combination parameter. A combination is a
-    #! quotation that takes some objects and a vtable from the
-    #! stack, and calls the appropriate row of the vtable.
-    [ swap "combination" set-word-prop ] keep
+: define-generic* ( picker dispatcher word -- )
+    [ swap "dispatcher" set-word-prop ] keep
+    [ swap "picker" set-word-prop ] keep
     dup init-methods make-generic ;
 
-: single-combination ( obj vtable -- )
-    >r dup type r> dispatch ; inline
+: define-generic ( word -- )
+    >r [ dup ] [ type ] r> define-generic* ;
 
 PREDICATE: compound generic ( word -- ? )
-    "combination" word-prop [ single-combination ] = ;
+    dup "dispatcher" word-prop [ type ] =
+    swap "picker" word-prop [ dup ] = and ;
 M: generic definer drop \ GENERIC: ;
 
-: single-combination ( obj vtable -- )
-    >r dup type r> dispatch ; inline
-
-: arithmetic-combination ( n n vtable -- )
-    #! Note that the numbers remain on the stack, possibly after
-    #! being coerced to a maximal type.
-    >r arithmetic-type r> dispatch ; inline
+: define-2generic ( word -- )
+    >r [ ] [ arithmetic-type ] r> define-generic* ;
 
 PREDICATE: compound 2generic ( word -- ? )
-    "combination" word-prop [ arithmetic-combination ] = ;
+    dup "dispatcher" word-prop [ arithmetic-type ] =
+    swap "picker" word-prop not and ;
 M: 2generic definer drop \ 2GENERIC: ;
 
 ! Maps lists of builtin type numbers to class objects.
index a9dc7adc3512881a6af796e2e5c0bb8d2575eeff..609aa214ece16deafcdc19e925dadf21647efa78 100644 (file)
@@ -11,8 +11,7 @@ sequences strings words ;
     #! Just like:
     #! GENERIC: generic
     #! M: class generic def ;
-    over [ single-combination ] swap
-    define-generic define-method ;
+    over define-generic define-method ;
 
 : define-slot-word ( class slot word quot -- )
     over [
index a1f07b41b761477eba69e57e2ed971a1bf7ff9a4..7b46257806328b2aecffaa3dd0c6910cb086810f 100644 (file)
@@ -31,7 +31,8 @@ M: tuple-seq length ( tuple-seq -- len )
 
 IN: generic
 
-BUILTIN: tuple 18 [ 1 length f ] ;
+DEFER: tuple?
+BUILTIN: tuple 18 tuple? [ 1 length f ] ;
 
 ! So far, only tuples can have delegates, which also must be
 ! tuples (the UI uses numbers as delegates in a couple of places
@@ -162,8 +163,8 @@ UNION: arrayed array tuple ;
     #! Generate a quotation that performs tuple class dispatch
     #! for methods defined on the given generic.
     dup default-tuple-method \ drop swons
-    swap tuple-methods hash>quot
-    [ dup class-tuple ] swap append ;
+    over tuple-methods hash>quot
+    >r "picker" word-prop [ class-tuple ] r> append3 ;
 
 : add-tuple-dispatch ( word vtable -- )
     >r tuple-dispatch-quot tuple r> set-vtable ;
index d4493a1cd0986e889807c5e0e7eb52a74e2f80dc..64e3c838048e0a21f844d558b20010e262a0136e 100644 (file)
@@ -19,9 +19,7 @@ stdio streams strings unparser http ;
 : chars>entities ( str -- str )
     #! Convert <, >, &, ' and " to HTML entities.
     [
-        [
-            dup html-entities assoc [ % ] [ , ] ?ifte
-        ] seq-each
+        [ dup html-entities assoc [ % ] [ , ] ?ifte ] each
     ] make-string ;
 
 : >hex-color ( triplet -- hex )
index 365f8131e449b8053e6969e734404c1de7af609f..cf00554aab34f906383834988e339570ddebfdad 100644 (file)
@@ -21,7 +21,7 @@ stdio streams strings unparser ;
             ] [
                 CHAR: % , >hex 2 CHAR: 0 pad %
             ] ifte
-        ] seq-each
+        ] each
     ] make-string ;
 
 : catch-hex> ( str -- n )
index f0abfd21d7f58282c52f6089a0c2f38a4467a20c..d8cfae230c115adb70c12aa2d70cabe9b7d6dd25 100644 (file)
@@ -37,7 +37,7 @@ sequences strings vectors words hashtables prettyprint ;
 : unify-stacks ( list -- stack )
     #! Replace differing literals in stacks with unknown
     #! results.
-    unify-lengths vector-transpose [ unify-results ] seq-map ; 
+    unify-lengths vector-transpose [ unify-results ] map ; 
 
 : balanced? ( list -- ? )
     #! Check if a list of [[ instack outstack ]] pairs is
@@ -84,7 +84,7 @@ SYMBOL: cloned
 
 : deep-clone-seq ( seq -- seq )
     #! Clone a sequence and each object it contains.
-    [ deep-clone ] seq-map ;
+    [ deep-clone ] map ;
 
 : copy-inference ( -- )
     #! We avoid cloning the same object more than once in order
index 6f38cc11bc208ef8fd224d7e8f5ba463acfd6b40..7bc1b4dabb131d9a38bc48367a69b81c5bb846be 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: inference
 USING: errors interpreter kernel lists namespaces prettyprint
-stdio ;
+sequences stdio ;
 
 DEFER: recursive-state
 
index 9c1599a7d471f78b64343c0facf0494cb05f2470..1f19e171969a013adaea9ba0561466b1a2442a94 100644 (file)
@@ -27,13 +27,14 @@ M: object clone ;
     #! Push t if cond is true, otherwise push f.
     rot [ drop ] [ nip ] ifte ; inline
 
-: >boolean t f ? ; inline
-: not ( a -- ~a ) f t ? ; inline
+! defined in parse-syntax.factor
+DEFER: not
+DEFER: t?
 
+: >boolean t f ? ; inline
 : and ( a b -- a&b ) f ? ; inline
 : or ( a b -- a|b ) t swap ? ; inline
 : xor ( a b -- a^b ) dup not swap ? ; inline
-: implies ( a b -- a->b ) t ? ; inline
 
 : cpu ( -- arch ) 7 getenv ;
 : os ( -- os ) 11 getenv ;
index cd580106cd2f6294edff855746f5f169dab49a58..08edbfb05f709e6c5555e05ae11cf5a9097bda3a 100644 (file)
@@ -10,7 +10,8 @@ USING: errors generic kernel kernel-internals math ;
 
 IN: math
 
-BUILTIN: complex 6 [ 0 "real" f ] [ 1 "imaginary" f ] ;
+DEFER: complex?
+BUILTIN: complex 6 complex? [ 0 "real" f ] [ 1 "imaginary" f ] ;
 UNION: number real complex ;
 
 M: real real ;
index 9ed49e52030b194c7fb381d1b52031c0e4b38caf..6e3b33346fe23633b18a36dd45fa0e703238e73c 100644 (file)
@@ -3,7 +3,8 @@
 IN: math
 USING: generic kernel math-internals ;
 
-BUILTIN: float 5 ;
+DEFER: float?
+BUILTIN: float 5 float? ;
 UNION: real rational float ;
 
 M: real abs dup 0 < [ neg ] when ;
index 0cae4cb17aa15be3871c888d41c558b3f9d17b94..7965a90fd6ae3fa43c5489ebeb0c2d73ad5500dd 100644 (file)
@@ -3,8 +3,10 @@
 IN: math
 USING: errors generic kernel math ;
 
-BUILTIN: fixnum 0 ;
-BUILTIN: bignum 1 ;
+DEFER: fixnum?
+BUILTIN: fixnum 0 fixnum? ;
+DEFER: bignum?
+BUILTIN: bignum 1 bignum? ;
 UNION: integer fixnum bignum ;
 
 : (gcd) ( b a y x -- a d )
index ada80744c88d34a35bf53a16a9f8be330df04ce8..94ff6437645cbc073d78e1d7d814436331e73092 100644 (file)
@@ -4,28 +4,28 @@ IN: math
 USING: errors generic kernel math-internals ;
 
 ! Math operations
-2GENERIC: number= ( x y -- ? )
+G: number= ( x y -- ? ) [ ] [ arithmetic-type ] ;
 M: object number= 2drop f ;
 
-2GENERIC: <  ( x y -- ? )
-2GENERIC: <= ( x y -- ? )
-2GENERIC: >  ( x y -- ? )
-2GENERIC: >= ( x y -- ? )
-
-2GENERIC: +   ( x y -- x+y )
-2GENERIC: -   ( x y -- x-y )
-2GENERIC: *   ( x y -- x*y )
-2GENERIC: /   ( x y -- x/y )
-2GENERIC: /i  ( x y -- x/y )
-2GENERIC: /f  ( x y -- x/y )
-2GENERIC: mod ( x y -- x%y )
-
-2GENERIC: /mod ( x y -- x/y x%y )
-
-2GENERIC: bitand ( x y -- z )
-2GENERIC: bitor  ( x y -- z )
-2GENERIC: bitxor ( x y -- z )
-2GENERIC: shift  ( x n -- y )
+G: <  ( x y -- ? ) [ ] [ arithmetic-type ] ;
+G: <= ( x y -- ? ) [ ] [ arithmetic-type ] ;
+G: >  ( x y -- ? ) [ ] [ arithmetic-type ] ;
+G: >= ( x y -- ? ) [ ] [ arithmetic-type ] ;
+
+G: +   ( x y -- x+y ) [ ] [ arithmetic-type ] ;
+G: -   ( x y -- x-y ) [ ] [ arithmetic-type ] ;
+G: *   ( x y -- x*y ) [ ] [ arithmetic-type ] ;
+G: /   ( x y -- x/y ) [ ] [ arithmetic-type ] ;
+G: /i  ( x y -- x/y ) [ ] [ arithmetic-type ] ;
+G: /f  ( x y -- x/y ) [ ] [ arithmetic-type ] ;
+G: mod ( x y -- x%y ) [ ] [ arithmetic-type ] ;
+
+G: /mod ( x y -- x/y x%y ) [ ] [ arithmetic-type ] ;
+
+G: bitand ( x y -- z ) [ ] [ arithmetic-type ] ;
+G: bitor  ( x y -- z ) [ ] [ arithmetic-type ] ;
+G: bitxor ( x y -- z ) [ ] [ arithmetic-type ] ;
+G: shift  ( x n -- y ) [ ] [ arithmetic-type ] ;
 
 GENERIC: bitnot ( n -- n )
 
index fdbc655dbd24fa94a43e46db37dd629c4e385a4a..b7a2a6044d713578c5617e43e1a7eca9ef771f15 100644 (file)
@@ -6,16 +6,16 @@ vectors ;
 
 : n*v ( n vec -- vec )
     #! Multiply a vector by a scalar.
-    [ * ] seq-map-with ;
+    [ * ] map-with ;
 
 ! Vector operations
-: v+ ( v v -- v ) [ + ] seq-2map ;
-: v- ( v v -- v ) [ - ] seq-2map ;
-: v* ( v v -- v ) [ * ] seq-2map ;
+: v+ ( v v -- v ) [ + ] 2map ;
+: v- ( v v -- v ) [ - ] 2map ;
+: v* ( v v -- v ) [ * ] 2map ;
 
 ! Later, this will fixed when seq-2each works properly
 ! : v. ( v v -- x ) 0 swap [ * + ] seq-2each ;
-: +/ ( seq -- n ) 0 swap [ + ] seq-each ;
+: +/ ( seq -- n ) 0 swap [ + ] each ;
 : v. ( v v -- x ) v* +/ ;
 
 ! Matrices
index 720dcb2ef003304a432e1242afdc0fd6c08554df..609a6fd0d9d4f5fc48f30a16679db99a6bbde59a 100644 (file)
@@ -3,7 +3,8 @@
 IN: math
 USING: generic kernel kernel-internals math math-internals ;
 
-BUILTIN: ratio 4 [ 0 "numerator" f ] [ 1 "denominator" f ] ;
+DEFER: ratio?
+BUILTIN: ratio 4 ratio? [ 0 "numerator" f ] [ 1 "denominator" f ] ;
 UNION: rational integer ratio ;
 
 M: integer numerator ;
index ff1dd52497526480100cd56f4a03e41cecce209c..3817ec7ffcb1404512f1667b77a10f530b534e1a 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2004, 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: sdl
-USING: alien lists namespaces kernel math hashtables ;
+USING: alien lists namespaces kernel math hashtables
+sequences ;
 
 : SDL_EnableUNICODE ( enable -- )
     "int" "sdl" "SDL_EnableUNICODE" [ "int" ] alien-invoke ;
index 6cf6b8f2679e4c1fa69b17638723223cc99cfc34..da1c710d0eb9dc4409064dc4c8b1a1d9c1839172 100644 (file)
@@ -6,20 +6,22 @@ IN: !syntax
 USING: syntax generic kernel lists namespaces parser words ;
 
 : GENERIC:
-    #! GENERIC: bar creates a generic word bar. Add methods to
-    #! the generic word using M:.
-    [ single-combination ] CREATE define-generic ; parsing
+    #! GENERIC: bar == G: bar [ dup ] [ type ] ;
+    CREATE define-generic ; parsing
 
 : 2GENERIC:
-    #! 2GENERIC: bar creates a generic word bar. Add methods to
-    #! the generic word using M:. 2GENERIC words dispatch on
-    #! arithmetic types and should not be used for non-numerical
-    #! types.
-    [ arithmetic-combination ] CREATE define-generic ; parsing
+    #! 2GENERIC: bar == G: bar [ ] [ arithmetic-type ] ;
+    #! 2GENERIC words dispatch on arithmetic types and should
+    #! not be used for non-numerical types.
+    CREATE define-2generic ; parsing
+
+: G:
+    #! G: word picker dispatcher ;
+    CREATE [ 2unlist rot define-generic* ] [ ] ; parsing
 
 : BUILTIN:
-    #! Syntax: BUILTIN: <class> <type#> <slots> ;
-    CREATE scan-word [ builtin-class ] [ ] ; parsing
+    #! Syntax: BUILTIN: <class> <type#> <predicate> <slots> ;
+    CREATE scan-word scan-word [ define-builtin ] [ ] ; parsing
 
 : COMPLEMENT: ( -- )
     #! Followed by a class name, then a complemented class.
@@ -60,4 +62,4 @@ USING: syntax generic kernel lists namespaces parser words ;
     #! Followed by a tuple name, then constructor code, then ;
     #! Constructor code executes with the empty tuple on the
     #! stack.
-    scan-word [ define-constructor ] f ; parsing
+    scan-word [ define-constructor ] [ ] ; parsing
index 4068270b9b9a25add391d007765e0dd29fb96bb9..41ca310a76a8efc6c3773ceb9fddc8e3b576a9ed 100644 (file)
@@ -20,7 +20,7 @@ M: object digit> not-a-number ;
     dup empty? [
         not-a-number
     ] [
-        0 swap [ digit> pick digit+ ] seq-each nip
+        0 swap [ digit> pick digit+ ] each nip
     ] ifte ;
 
 : base> ( str base -- num )
index c979edc649d11381f249371a0f99406b4860d7eb..fb764f581323ae3307ab8bf8e6c1a46dc7ae3905 100644 (file)
@@ -23,14 +23,15 @@ words ;
 
 ! Booleans
 
-! The canonical t is a heap-allocated dummy object. It is always
-! the first in the image.
-BUILTIN: t 7 ;  : t t swons ; parsing
+! The canonical t is a heap-allocated dummy object.
+BUILTIN: t 7 t? ;
+: t t swons ; parsing
 
 ! In the runtime, the canonical f is represented as a null
 ! pointer with tag 3. So
 ! f address . ==> 3
-BUILTIN: f 9 ;  : f f swons ; parsing
+BUILTIN: f 9 not ;
+: f f swons ; parsing
 
 ! Lists
 : [ f ; parsing
index 88ed00c9ba4591b5b6fe08f0c09053190183ce7e..b27a1c564c5157dcfa4a955b7b53ff1bf0aa6a09 100644 (file)
@@ -181,7 +181,7 @@ M: matrix prettyprint* ( indent obj -- indent )
 
 : [.] ( sequence -- )
     #! Unparse each element on its own line.
-    [ . ] seq-each ;
+    [ . ] each ;
 
 : .s datastack  reverse [.] flush ;
 : .r callstack  reverse [.] flush ;
index 6dc0575bba1ceac33c5642c29e30fca0e744c3d5..4035f67d537e718973cd6c6e6c7442f16d3dc606 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: prettyprint
 USING: generic hashtables kernel lists math namespaces
-presentation stdio streams strings unparser words ;
+sequences stdio streams strings unparser words ;
 
 ! Prettyprinting words
 : vocab-actions ( search -- list )
index f85832e8b763fce7d7cb3ac8c20003f58fabad71..4e92ff1c7af242db757e5f60bc3a0e1535af1734 100644 (file)
@@ -87,7 +87,7 @@ M: complex unparse ( num -- str )
         dup ch>ascii-escape [ ] [ ch>unicode-escape ] ?ifte
     ] unless ;
 
-: unparse-string [ unparse-ch , ] seq-each ;
+: unparse-string [ unparse-ch , ] each ;
 
 M: string unparse ( str -- str )
     [ CHAR: " , unparse-string CHAR: " , ] make-string ;
index c5fada852d48217eb2989eb0f015e3cead71997a..1518dc48bfc694c06d50a9f6e8060f8054c4cd82 100644 (file)
@@ -1,5 +1,5 @@
 IN: temporary
-USING: parser prettyprint sequences stdio unparser ;
+USING: parser prettyprint sequences stdio strings unparser ;
 
 USE: hashtables
 USE: namespaces
@@ -157,3 +157,15 @@ M: number union-containment drop 2 ;
 "GENERIC: unhappy" eval
 [ "M: vocabularies unhappy ;" eval ] unit-test-fails
 [ ] [ "GENERIC: unhappy" eval ] unit-test
+
+G: complex-combination [ over ] [ type ] ;
+M: string complex-combination drop ;
+M: object complex-combination nip ;
+
+[ "hi" ] [ "hi" 3 complex-combination ] unit-test
+[ "hi" ] [ 3 "hi" complex-combination ] unit-test
+
+TUPLE: shit ;
+
+M: shit complex-combination cons ;
+[ [[ << shit f >> 5 ]] ] [ << shit f >> 5 complex-combination ] unit-test
index 607e80ac586340559035e4741a4e915afdb54046..fbed1f52f543e337b3df4a9b88d0dd311f3fdb86 100644 (file)
@@ -80,13 +80,13 @@ unit-test
 
 [ 4 ] [
     0 "There are Four Upper Case characters"
-    [ LETTER? [ 1 + ] when ] seq-each
+    [ LETTER? [ 1 + ] when ] each
 ] unit-test
 
 [ "Replacing+spaces+with+plus" ]
 [
     "Replacing spaces with plus"
-    [ dup CHAR: \s = [ drop CHAR: + ] when ] seq-map
+    [ dup CHAR: \s = [ drop CHAR: + ] when ] map
 ]
 unit-test
 
index 713459797824cc369c9d646dc6ad173cdafc330a..1d34ca79ba51b007c9c006582056422bcfa8d52b 100644 (file)
@@ -25,7 +25,7 @@ sequences strings test vectors ;
 [ { 1 2 } ] [ [ 1 2 ] >vector ] unit-test
 
 [ t ] [
-    100 empty-vector [ drop 0 100 random-int ] seq-map
+    100 empty-vector [ drop 0 100 random-int ] map
     dup >list >vector =
 ] unit-test
 
@@ -37,7 +37,7 @@ sequences strings test vectors ;
 [ [ 1 4 9 16 ] ]
 [
     [ 1 2 3 4 ]
-    >vector [ dup * ] seq-map >list
+    >vector [ dup * ] map >list
 ] unit-test
 
 [ t ] [ { } hashcode { } hashcode = ] unit-test
index bd93629d45cddcd5be04c19593cac7df476334cb..2408e0c57d65ca28d10cab6c41353b89c942c3a9 100644 (file)
@@ -2,8 +2,8 @@
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: words
 USING: files generic inspector lists kernel namespaces
-prettyprint stdio streams strings unparser math hashtables
-parser ;
+prettyprint stdio streams strings sequences unparser math
+hashtables parser ;
 
 : vocab-apropos ( substring vocab -- list )
     #! Push a list of all words in a vocabulary whose names
index cf4e139288267e35ac2ea8e19529a2dc4c1f15b5..4e2c268f6ee550a4f2df2c635b56891bb94f652e 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: gadgets
 USING: generic kernel lists math namespaces prettyprint sdl
-sequences stdio ;
+sequences stdio sequences ;
 
 : button-down? ( n -- ? ) hand hand-buttons contains? ;
 
index 9def3426c339ceef6f86f226dab20f13937a05a9..060c9ada42fb88491e7c0eccbbe6a00bb40c6300 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: gadgets
-USING: generic kernel lists math namespaces sdl ;
+USING: generic kernel lists math namespaces sdl sequences ;
 
 : check-size 8 ;
 
index c4703b830cd650c36df854ff2eabf9fbf2e96f29..e8e065ed2a067ba10d11757d9bb0571980f43832 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: gadgets
-USING: gadgets generic kernel lists math namespaces sdl words ;
+USING: gadgets generic kernel lists math namespaces sdl
+sequences words ;
 
 ! A frame arranges left/right/top/bottom gadgets around a
 ! center gadget, which gets any leftover space.
index 03734775d3f235966c92ee0861e076f9b66e83d2..dc1d50a24cc321c92e4ee5e4737e44aef076202f 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: gadgets
-USING: generic hashtables kernel lists math namespaces ;
+USING: generic hashtables kernel lists math namespaces
+sequences ;
 
 ! A gadget is a shape, a paint, a mapping of gestures to
 ! actions, and a reference to the gadget's parent. A gadget
index eb3337c5b7c1beec85fa13d6e7a0456a3c585b80..334c936a293ed38906420ed606487dd8745f25c2 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: gadgets
-USING: alien generic hashtables kernel lists math sdl ;
+USING: alien generic hashtables kernel lists math sdl
+sequences ;
 
 : action ( gadget gesture -- quot )
     swap gadget-gestures hash ;
index 09b8d66a8ffd2c0d532cbd16e4ea566c2a18737d..758c3d01420496a2377072d099e6b34d00bee7de 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: gadgets
-USING: generic kernel lists math namespaces sdl stdio ;
+USING: generic kernel lists math namespaces sdl stdio
+sequences ;
 
 ! A label gadget draws a string.
 TUPLE: label text ;
index d22a99de18a4f4045d9a985dcdc72800a5fb089b..8b9067af3cad47d5e7480f10607faf341176ed3c 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: gadgets
 USING: errors generic hashtables kernel lists math namespaces
-sdl ;
+sdl sequences ;
 
 : layout ( gadget -- )
     #! Set the gadget's width and height to its preferred width
index 0018d7d467c290d55e0129aebf1eb3db2ad7e902..55cefbc3a576a021cb711dab18d2b600dae22963 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: gadgets
 USING: generic hashtables kernel lists math namespaces sdl
-stdio strings ;
+stdio strings sequences ;
 
 ! Clipping
 
index d3f7bcf1076a7fb01f0dae93927a43cbbc76a06c..6a6766ce85f673a54500ef3d0bb4cc2a8b9b791d 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: gadgets
 USING: errors generic hashtables kernel lists math namespaces
-sdl ;
+sdl sequences ;
 
 ! A stack just lays out all its children on top of each other.
 TUPLE: stack ;
index 9a43602a669dff5ece2aa6f0297164d06e8506fb..c8cccb42ae7c211c384e8b77693444befc6d3ab8 100644 (file)
@@ -52,7 +52,7 @@ global [
 
 : filter-nulls ( str -- str )
     "\0" over string-contains? [
-        [ dup CHAR: \0 = [ drop CHAR: \s ] when ] seq-map
+        [ dup CHAR: \0 = [ drop CHAR: \s ] when ] map
     ] when ;
 
 : size-string ( font text -- w h )
index ba04ffcdfe5268c7b047c3f89cc89210730d883b..c55fdb8a106f9a52f866d8fb009c8cb0f7a40a3e 100644 (file)
@@ -3,7 +3,7 @@
 IN: gadgets
 USING: alien errors generic kernel lists math
 memory namespaces prettyprint sdl sequences stdio strings
-threads ;
+threads sequences ;
 
 ! The world gadget is the top level gadget that all (visible)
 ! gadgets are contained in. The current world is stored in the
index 657818e1858cb249e7e5168fbb565329c541aa11..09f78613e3308883c7c8d0e83823098766992b81 100644 (file)
@@ -6,7 +6,8 @@ namespaces sequences strings vectors ;
 
 ! The basic word type. Words can be named and compared using
 ! identity. They hold a property map.
-BUILTIN: word 17
+DEFER: word?
+BUILTIN: word 17 word?
     [ 1 hashcode f ]
     [ 4 "word-def" "set-word-def" ]
     [ 5 "word-props" "set-word-props" ] ;
@@ -130,5 +131,6 @@ M: compound definer drop \ : ;
     #! If the word is a generic word, clear the properties 
     #! involved so that 'see' can work properly.
     over f "methods" set-word-prop
-    over f "combination" set-word-prop
+    over f "picker" set-word-prop
+    over f "dispatcher" set-word-prop
     (define-compound) ;