Merge branch 'master' of git://factorcode.org/git/factor

db4
Slava Pestov 2008-08-01 23:31:55 -05:00
commit aabeb53753
21 changed files with 109 additions and 27 deletions

View File

@ -56,19 +56,19 @@ ARTICLE: { "concurrency" "synchronous-sends" } "Synchronous sends"
"USING: concurrency.messaging kernel threads ;"
": pong-server ( -- )"
" receive >r \"pong\" r> reply-synchronous ;"
"[ pong-server t ] spawn-server"
"[ pong-server t ] \"pong-server\" spawn-server"
"\"ping\" swap send-synchronous ."
"\"pong\""
} ;
ARTICLE: { "concurrency" "exceptions" } "Linked exceptions"
"A thread can handle exceptions using the standard Factor exception handling mechanism. If an exception is uncaught the thread will terminate. For example:"
{ $code "[ 1 0 / \"This will not print\" print ] spawn" }
{ $code "[ 1 0 / \"This will not print\" print ] \"division-by-zero\" spawn" }
"Processes can be linked so that a parent thread can receive the exception that caused the child thread to terminate. In this way 'supervisor' threades can be created that are notified when child threades terminate and possibly restart them."
{ $subsection spawn-linked }
"This will create a unidirectional link, such that if an uncaught exception causes the child to terminate, the parent thread can catch it:"
{ $code "["
" [ 1 0 / \"This will not print\" print ] spawn-linked drop"
" [ 1 0 / \"This will not print\" print ] \"linked-division\" spawn-linked drop"
" receive"
"] [ \"Exception caught.\" print ] recover" }
"Exceptions are only raised in the parent when the parent does a " { $link receive } " or " { $link receive-if } ". This is because the exception is sent from the child to the parent as a message." ;

1
extra/24-game/tags.txt Normal file
View File

@ -0,0 +1 @@
demos

View File

@ -0,0 +1 @@
demos

View File

@ -0,0 +1 @@
demos

View File

@ -0,0 +1 @@
demos

View File

@ -0,0 +1 @@
demos

View File

@ -0,0 +1 @@
demos

View File

@ -0,0 +1 @@
demos

View File

@ -0,0 +1,63 @@
USING: namespaces sequences math random-weighted cfdg ;
IN: cfdg.models.rules08
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
: insct ( -- )
[ 1.5 5.5 size* -1 brightness triangle ] do
10
[ [ [ 1 0.9 size* -0.15 y 0.05 brightness ] times 1 5 size* triangle ] do ]
each ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
DEFER: line
: ligne ( -- )
{
{ 1 [ 1.15 0.8 size* 4.5 y -0.3 b line ] do }
{ 0.5 [ ] }
}
call-random-weighted ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
: line ( -- ) [ insct ligne ] recursive ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
: sole ( -- )
[
{
{
1 [
[ 1 brightness 0.5 saturation ligne ] do
[ 140 r 1 hue sole ] do
]
}
{ 0.01 [ ] }
}
call-random-weighted
]
recursive ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
: centre ( -- )
[ 1 b 5 s circle ] do
[ sole ] do ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
: run ( -- )
[ -1 b ] >background
{ -20 40 -20 40 } viewport set
[ centre ] >start-shape
0.0001 >threshold
cfdg-window ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
MAIN: run

View File

@ -0,0 +1 @@
demos

View File

@ -0,0 +1 @@
demos

View File

@ -0,0 +1 @@
demos

1
extra/lsys/ui/tags.txt Normal file
View File

@ -0,0 +1 @@
demos

View File

@ -0,0 +1 @@
demos

View File

@ -0,0 +1 @@
demos

View File

@ -0,0 +1 @@
demos

View File

@ -0,0 +1 @@
demos

View File

@ -0,0 +1 @@
demos

View File

@ -0,0 +1 @@
demos

View File

@ -0,0 +1 @@
demos

View File

@ -1,8 +1,9 @@
! Copyright (C) 2007 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.accessors arrays assocs combinators.lib io kernel
macros math namespaces prettyprint quotations sequences
vectors vocabs words html.elements slots.private tar ;
USING: accessors alien alien.accessors arrays assocs
combinators.lib io kernel macros math namespaces prettyprint
quotations sequences vectors vocabs words html.elements sets
slots.private combinators.short-circuit ;
IN: lint
SYMBOL: def-hash
@ -18,7 +19,7 @@ SYMBOL: def-hash-keys
2drop
] if ;
: more-defs
: more-defs ( -- )
{
{ [ swap >r swap r> ] -rot }
{ [ swap swapd ] -rot }
@ -33,6 +34,7 @@ SYMBOL: def-hash-keys
{ [ 0 = ] zero? }
{ [ pop drop ] pop* }
{ [ [ ] if ] when }
{ [ f = not ] >boolean }
} [ first2 swap add-word-def ] each ;
: accessor-words ( -- seq )
@ -51,33 +53,32 @@ SYMBOL: def-hash-keys
{
[ get ] [ t ] [ { } ] [ . ] [ drop f ]
[ drop ] [ f ] [ first ] [ second ] [ third ] [ fourth ]
[ ">" write-html ] [ <unimplemented-typeflag> throw ]
[ "/>" write-html ]
[ ">" write-html ] [ "/>" write-html ]
} ;
H{ } clone def-hash set-global
all-words [ dup word-def add-word-def ] each
all-words [ dup def>> add-word-def ] each
more-defs
! Remove empty word defs
def-hash get-global [
drop empty? not
] assoc-subset
] assoc-filter
! Remove constants [ 1 ]
[
drop dup length 1 = swap first number? and not
] assoc-subset
] assoc-filter
! Remove set-alien-cell, etc.
[
drop [ accessor-words swap seq-diff ] keep [ length ] bi@ =
] assoc-subset
drop [ accessor-words diff ] keep [ length ] bi@ =
] assoc-filter
! Remove trivial defs
[
drop trivial-defs member? not
] assoc-subset
] assoc-filter
! Remove n m shift defs
[
@ -85,19 +86,19 @@ def-hash get-global [
dup first2 [ number? ] both?
swap third \ shift = and not
] [ drop t ] if
] assoc-subset
] assoc-filter
! Remove [ n slot ]
[
drop dup length 2 = [
first2 \ slot = swap number? and not
] [ drop t ] if
] assoc-subset def-hash set-global
] assoc-filter def-hash set-global
: find-duplicates
: find-duplicates ( -- seq )
def-hash get-global [
nip length 1 >
] assoc-subset ;
] assoc-filter ;
def-hash get-global keys def-hash-keys set-global
@ -107,18 +108,18 @@ M: object lint ( obj -- seq )
drop f ;
: subseq/member? ( subseq/member seq -- ? )
{ [ 2dup start ] [ 2dup member? ] } || 2nip ;
{ [ start ] [ member? ] } 2|| ;
M: callable lint ( quot -- seq )
def-hash-keys get [
swap subseq/member?
] with subset ;
] with filter ;
M: word lint ( word -- seq )
word-def dup callable? [ lint ] [ drop f ] if ;
def>> dup callable? [ lint ] [ drop f ] if ;
: word-path. ( word -- )
[ word-vocabulary ":" ] keep unparse 3append write nl ;
[ vocabulary>> ":" ] keep unparse 3append write nl ;
: (lint.) ( pair -- )
first2 >r word-path. r> [
@ -135,7 +136,7 @@ M: word lint ( word -- seq )
GENERIC: run-lint ( obj -- obj )
: (trim-self)
: (trim-self) ( val key -- obj ? )
def-hash get-global at* [
dupd remove empty? not
] [
@ -143,13 +144,13 @@ GENERIC: run-lint ( obj -- obj )
] if ;
: trim-self ( seq -- newseq )
[ [ (trim-self) ] subset ] assoc-map ;
[ [ (trim-self) ] filter ] assoc-map ;
: filter-symbols ( alist -- alist )
[
nip first dup def-hash get at
[ first ] bi@ literalize = not
] assoc-subset ;
] assoc-filter ;
M: sequence run-lint ( seq -- seq )
[
@ -157,7 +158,7 @@ M: sequence run-lint ( seq -- seq )
dup lint
] { } map>assoc
trim-self
[ second empty? not ] subset
[ second empty? not ] filter
filter-symbols ;
M: word run-lint ( word -- seq )