diff --git a/CHANGES.html b/CHANGES.html
index 6a6ed71ddf..19f0dbe12c 100644
--- a/CHANGES.html
+++ b/CHANGES.html
@@ -46,6 +46,7 @@
Everything else:
+- New
make-hash ( quot -- namespace )
combinator executes quotation in a new namespace, which is then pushed on the stack.
- Erlang/Termite-style concurrency library in
contrib/concurrency
(Chris Double).
- Object slots are now clickable in the inspector
- The matrices library has been greatly simplified. Matrices are now represented as vectors of vectors, and matrix words have been moved to the
math
vocabulary.
diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt
index 6edbdf3d82..957b2c2689 100644
--- a/TODO.FACTOR.txt
+++ b/TODO.FACTOR.txt
@@ -1,13 +1,6 @@
-+ messy code hall of shame:
-
-- alien/c-types.factor is ugly
-- compile-byte/cell: instantiating aliens
-- buffer: instantiating aliens
-
-- flushing optimization
- reader syntax for arrays, byte arrays, displaced aliens
-- split, group: return vectors
- sleep word
+- docstrings appear twice
+ ui:
@@ -56,6 +49,7 @@
+ ffi:
+- alien/c-types.factor is ugly
- smarter out parameter handling
- clarify powerpc passing of value struct parameters
- ffi unicode strings: null char security hole
@@ -66,6 +60,8 @@
+ compiler:
+- flushing optimization
+- compile-byte/cell: instantiating aliens
- changing a word to be 'inline' after it was already defined doesn't
work properly
- inference needs to be more robust with heavily recursive code
@@ -84,22 +80,21 @@
+ kernel:
+- split, group: return vectors
- specialized arrays
-- clear "predicating" word prop when redefining words
+- clear special word props when redefining words
- there is a problem with hashcodes of words and bootstrapping
- delegating generic words with a non-standard picker
- powerpc has weird callstack residue
- instances: do not use make-list
-- method doc strings
- vectors: ensure its ok with bignum indices
- code gc
-- doc comments of generics
+ i/o:
+- buffer: instantiating aliens
- faster stream-copy
- reading and writing byte arrays
-- unix io: handle \n\r and \n\0
- stream server can hang because of exception handler limitations
- better i/o scheduler
- utf16, utf8 encoding
diff --git a/library/collections/sequence-sort.factor b/library/collections/sequence-sort.factor
index a5829f6b89..58429e0987 100644
--- a/library/collections/sequence-sort.factor
+++ b/library/collections/sequence-sort.factor
@@ -3,7 +3,7 @@ USING: kernel math sequences ;
: midpoint ( seq -- elt ) dup length 2 /i swap nth ; inline
-TUPLE: sorter seq start end mid ;
+TUPLE: sorter start end mid ;
C: sorter ( seq start end -- sorter )
[ >r 1 + rot r> set-sorter-seq ] keep
diff --git a/library/generic/generic.factor b/library/generic/generic.factor
index 77ebfe1169..9ab74d8dec 100644
--- a/library/generic/generic.factor
+++ b/library/generic/generic.factor
@@ -75,16 +75,12 @@ SYMBOL: builtin
[ "methods" word-prop remove-hash ] keep make-generic ;
: init-methods ( word -- )
- dup "methods" word-prop [
- drop
- ] [
- "methods" set-word-prop
- ] ifte ;
+ dup "methods" word-prop
+ [ drop ] [ "methods" set-word-prop ] ifte ;
! Defining generic words
-: define-generic* ( picker combination word -- )
- [ swap "combination" set-word-prop ] keep
- [ swap "picker" set-word-prop ] keep
+: define-generic* ( word combination -- )
+ dupd "combination" set-word-prop
dup init-methods make-generic ;
PREDICATE: compound generic ( word -- ? )
@@ -92,9 +88,6 @@ PREDICATE: compound generic ( word -- ? )
M: generic definer drop \ G: ;
-PREDICATE: generic simple-generic ( word -- ? )
- "picker" word-prop [ dup ] = ;
-
: lookup-union ( typelist -- class )
[ - ] sort typemap get hash [ object ] unless* ;
diff --git a/library/generic/standard-combination.factor b/library/generic/standard-combination.factor
index 139944b6e5..b0b8741568 100644
--- a/library/generic/standard-combination.factor
+++ b/library/generic/standard-combination.factor
@@ -2,29 +2,22 @@ IN: generic
USING: errors hashtables kernel kernel-internals lists math
namespaces sequences vectors words ;
-: picker% "picker" word-prop % ;
-
-: error-method ( generic -- method )
- [ dup picker% literalize , \ no-method , ] make-list ;
+: error-method ( picker word -- method )
+ [ swap % literalize , \ no-method , ] make-list ;
DEFER: delegate
-: empty-method ( generic -- method )
- dup "picker" word-prop [ dup ] = [
+: empty-method ( picker word -- method )
+ over [ dup ] = [
[
- [ dup delegate ] %
- [ dup , ] make-list ,
- error-method ,
- \ ?ifte ,
+ [ dup delegate ] % dup unit , error-method , \ ?ifte ,
] make-list
] [
error-method
] ifte ;
-: class-predicates ( generic assoc -- assoc )
- >r "picker" word-prop r> [
- uncons >r "predicate" word-prop append r> cons
- ] map-with ;
+: class-predicates ( picker assoc -- assoc )
+ [ uncons >r "predicate" word-prop append r> cons ] map-with ;
: alist>quot ( default alist -- quot )
[ unswons [ % , , \ ifte , ] make-list ] each ;
@@ -37,22 +30,28 @@ DEFER: delegate
[ 2drop f ] ifte
] map-with ;
-: ( generic -- vtable )
- dup dup methods sort-methods [ class-predicates ] map-with
+: ( picker word -- vtable )
+ 2dup methods sort-methods [ class-predicates ] map-with
>r empty-method r> [ alist>quot ] map-with ;
-: small-generic ( word -- def )
- dup dup methods class-predicates
- >r empty-method r> alist>quot ;
+: small-generic ( picker word -- def )
+ 2dup methods class-predicates >r empty-method r> alist>quot ;
-: big-generic ( word -- def )
- [ dup picker% \ type , , \ dispatch , ] make-list ;
+: big-generic ( picker word -- def )
+ [ over % \ type , , \ dispatch , ] make-list ;
: small-generic? ( word -- ? )
"methods" word-prop hash-size 3 <= ;
-: standard-combination ( word -- quot )
- dup small-generic? [ small-generic ] [ big-generic ] ifte ;
+: standard-combination ( word picker -- quot )
+ swap dup small-generic?
+ [ small-generic ] [ big-generic ] ifte ;
+
+: simple-combination ( word -- quot )
+ [ dup ] standard-combination ;
: define-generic ( word -- )
- >r [ dup ] [ standard-combination ] r> define-generic* ;
+ [ simple-combination ] define-generic* ;
+
+PREDICATE: generic simple-generic ( word -- ? )
+ "combination" word-prop [ simple-combination ] = ;
diff --git a/library/generic/union.factor b/library/generic/union.factor
index 04061682af..e091a5669b 100644
--- a/library/generic/union.factor
+++ b/library/generic/union.factor
@@ -9,16 +9,9 @@ SYMBOL: union
: union-predicate ( members -- list )
[
- [
- \ dup ,
- unswons "predicate" word-prop %
- [ drop t ] ,
- union-predicate ,
- \ ifte ,
- ] make-list
- ] [
- [ drop f ]
- ] ifte* ;
+ "predicate" word-prop
+ [ dup ] swap add [ drop t ] cons
+ ] map [ drop f ] swap alist>quot ;
: set-members ( class members -- )
2dup [ types ] map concat "types" set-word-prop
diff --git a/library/syntax/generic.factor b/library/syntax/generic.factor
index 4a58b3b0fe..d7190b5cf9 100644
--- a/library/syntax/generic.factor
+++ b/library/syntax/generic.factor
@@ -3,15 +3,16 @@
! Bootstrapping trick; see doc/bootstrap.txt.
IN: !syntax
-USING: syntax generic kernel lists namespaces parser words ;
+USING: generic kernel lists namespaces parser sequences syntax
+words ;
: GENERIC:
- #! GENERIC: bar == G: bar [ dup ] [ type ] ;
+ #! GENERIC: bar == G: bar simple-combination ;
CREATE define-generic ; parsing
: G:
- #! G: word picker dispatcher ;
- CREATE [ 2unlist rot define-generic* ] [ ] ; parsing
+ #! G: word combination ;
+ CREATE [ define-generic* ] [ ] ; parsing
: COMPLEMENT: ( -- )
#! Followed by a class name, then a complemented class.
diff --git a/library/syntax/see.factor b/library/syntax/see.factor
index a518860f56..488338df9d 100644
--- a/library/syntax/see.factor
+++ b/library/syntax/see.factor
@@ -75,7 +75,7 @@ M: compound (see)
M: generic (see)