<li>Everything else:
<ul>
+<li>New <code>make-hash ( quot -- namespace )</code> combinator executes quotation in a new namespace, which is then pushed on the stack.</li>
<li>Erlang/Termite-style concurrency library in <code>contrib/concurrency</code> (Chris Double).</li>
<li>Object slots are now clickable in the inspector</li>
<li>The matrices library has been greatly simplified. Matrices are now represented as vectors of vectors, and matrix words have been moved to the <code>math</code> vocabulary.</li>
-+ messy code hall of shame:\r
-\r
-- alien/c-types.factor is ugly\r
-- compile-byte/cell: instantiating aliens\r
-- buffer: instantiating aliens\r
-\r
-- flushing optimization\r
- reader syntax for arrays, byte arrays, displaced aliens\r
-- split, group: return vectors\r
- sleep word\r
+- docstrings appear twice\r
\r
+ ui:\r
\r
\r
+ ffi:\r
\r
+- alien/c-types.factor is ugly\r
- smarter out parameter handling\r
- clarify powerpc passing of value struct parameters\r
- ffi unicode strings: null char security hole\r
\r
+ compiler:\r
\r
+- flushing optimization\r
+- compile-byte/cell: instantiating aliens\r
- changing a word to be 'inline' after it was already defined doesn't\r
work properly\r
- inference needs to be more robust with heavily recursive code\r
\r
+ kernel:\r
\r
+- split, group: return vectors\r
- specialized arrays\r
-- clear "predicating" word prop when redefining words\r
+- clear special word props when redefining words\r
- there is a problem with hashcodes of words and bootstrapping\r
- delegating generic words with a non-standard picker\r
- powerpc has weird callstack residue\r
- instances: do not use make-list\r
-- method doc strings\r
- vectors: ensure its ok with bignum indices\r
- code gc\r
-- doc comments of generics\r
\r
+ i/o:\r
\r
+- buffer: instantiating aliens\r
- faster stream-copy\r
- reading and writing byte arrays\r
-- unix io: handle \n\r and \n\0\r
- stream server can hang because of exception handler limitations\r
- better i/o scheduler\r
- utf16, utf8 encoding\r
: 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 <slice> r> set-sorter-seq ] keep
[ "methods" word-prop remove-hash ] keep make-generic ;
: init-methods ( word -- )
- dup "methods" word-prop [
- drop
- ] [
- <namespace> "methods" set-word-prop
- ] ifte ;
+ dup "methods" word-prop
+ [ drop ] [ <namespace> "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 -- ? )
M: generic definer drop \ G: ;
-PREDICATE: generic simple-generic ( word -- ? )
- "picker" word-prop [ dup ] = ;
-
: lookup-union ( typelist -- class )
[ - ] sort typemap get hash [ object ] unless* ;
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 ;
[ 2drop f ] ifte
] map-with ;
-: <vtable> ( generic -- vtable )
- dup dup methods sort-methods [ class-predicates ] map-with
+: <vtable> ( 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 , <vtable> , \ dispatch , ] make-list ;
+: big-generic ( picker word -- def )
+ [ over % \ type , <vtable> , \ 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 ] = ;
: 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
! 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.
M: generic (see)
<block
- dup dup { "picker" "combination" } [ word-prop ] map-with
+ dup dup "combination" word-prop
swap see-body block; t newline
dup methods [ method. ] each-with ;