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

db4
John Benediktsson 2009-05-16 15:56:06 -07:00
commit 67ff15a3de
267 changed files with 1236 additions and 1041 deletions

View File

@ -1,11 +1,11 @@
! Copyright (C) 2004, 2009 Slava Pestov. ! Copyright (C) 2004, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: byte-arrays arrays assocs kernel kernel.private libc math USING: byte-arrays arrays assocs kernel kernel.private libc math
namespaces make parser sequences strings words assocs splitting namespaces make parser sequences strings words splitting math.parser
math.parser cpu.architecture alien alien.accessors alien.strings cpu.architecture alien alien.accessors alien.strings quotations
quotations layouts system compiler.units io io.files layouts system compiler.units io io.files io.encodings.binary
io.encodings.binary io.streams.memory accessors combinators effects io.streams.memory accessors combinators effects continuations fry
continuations fry classes ; classes ;
IN: alien.c-types IN: alien.c-types
DEFER: <int> DEFER: <int>

View File

@ -23,7 +23,7 @@ WHERE
: *T ( alien -- z ) : *T ( alien -- z )
[ T-real ] [ T-imaginary ] bi rect> ; inline [ T-real ] [ T-imaginary ] bi rect> ; inline
T in get T current-vocab
{ { N "real" } { N "imaginary" } } { { N "real" } { N "imaginary" } }
define-struct define-struct

View File

@ -421,7 +421,7 @@ PRIVATE>
: define-fortran-record ( name vocab fields -- ) : define-fortran-record ( name vocab fields -- )
[ >lower ] [ ] [ fortran-record>c-struct ] tri* define-struct ; [ >lower ] [ ] [ fortran-record>c-struct ] tri* define-struct ;
SYNTAX: RECORD: scan in get parse-definition define-fortran-record ; SYNTAX: RECORD: scan current-vocab parse-definition define-fortran-record ;
: set-fortran-abi ( library -- ) : set-fortran-abi ( library -- )
library-fortran-abis get-global at fortran-abi set ; library-fortran-abis get-global at fortran-abi set ;

View File

@ -1,6 +1,5 @@
USING: accessors alien.c-types strings help.markup help.syntax USING: alien.c-types strings help.markup help.syntax alien.syntax
alien.syntax sequences io arrays kernel words assocs namespaces sequences io arrays kernel words assocs namespaces ;
accessors ;
IN: alien.structs IN: alien.structs
ARTICLE: "c-structs" "C structure types" ARTICLE: "c-structs" "C structure types"

View File

@ -22,7 +22,7 @@ SYNTAX: TYPEDEF:
scan scan typedef ; scan scan typedef ;
SYNTAX: C-STRUCT: SYNTAX: C-STRUCT:
scan in get parse-definition define-struct ; scan current-vocab parse-definition define-struct ;
SYNTAX: C-UNION: SYNTAX: C-UNION:
scan parse-definition define-union ; scan parse-definition define-union ;

View File

@ -104,7 +104,7 @@ M:: lsb0-bit-writer poke ( value n bs -- )
widthed widthed
bs widthed>> #bits>> 8 swap - split-widthed :> remainder :> byte bs widthed>> #bits>> 8 swap - split-widthed :> remainder :> byte
byte bs widthed>> |widthed :> new-byte byte bs widthed>> |widthed :> new-byte
new-byte #bits>> dup 8 > [ "oops" throw ] when 8 = [ new-byte #bits>> 8 = [
new-byte bits>> bs bytes>> push new-byte bits>> bs bytes>> push
zero-widthed bs (>>widthed) zero-widthed bs (>>widthed)
remainder widthed>bytes remainder widthed>bytes

View File

@ -1,13 +1,14 @@
! Copyright (C) 2007, 2009 Slava Pestov. ! Copyright (C) 2007, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors compiler cpu.architecture vocabs.loader system USING: accessors cpu.architecture vocabs.loader system
sequences namespaces parser kernel kernel.private classes sequences namespaces parser kernel kernel.private classes
classes.private arrays hashtables vectors classes.tuple sbufs classes.private arrays hashtables vectors classes.tuple sbufs
hashtables.private sequences.private math classes.tuple.private hashtables.private sequences.private math classes.tuple.private
growable namespaces.private assocs words command-line vocabs io growable namespaces.private assocs words command-line vocabs io
io.encodings.string libc splitting math.parser memory io.encodings.string libc splitting math.parser memory compiler.units
compiler.units math.order compiler.tree.builder math.order compiler.tree.builder compiler.tree.optimizer
compiler.tree.optimizer compiler.cfg.optimizer ; compiler.cfg.optimizer ;
FROM: compiler => enable-optimizer compile-word ;
IN: bootstrap.compiler IN: bootstrap.compiler
! Don't bring this in when deploying, since it will store a ! Don't bring this in when deploying, since it will store a

View File

@ -1,15 +1,14 @@
! Copyright (C) 2004, 2009 Slava Pestov. ! Copyright (C) 2004, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: alien arrays byte-arrays generic assocs hashtables assocs USING: alien arrays byte-arrays generic hashtables hashtables.private
hashtables.private io io.binary io.files io.encodings.binary io io.binary io.files io.encodings.binary io.pathnames kernel
io.pathnames kernel kernel.private math namespaces make parser kernel.private math namespaces make parser prettyprint sequences
prettyprint sequences sequences.private strings sbufs vectors words strings sbufs vectors words quotations assocs system layouts splitting
quotations assocs system layouts splitting grouping growable classes grouping growable classes classes.builtin classes.tuple
classes.builtin classes.tuple classes.tuple.private vocabs classes.tuple.private vocabs vocabs.loader source-files definitions
vocabs.loader source-files definitions debugger quotations.private debugger quotations.private combinators math.order math.private
sequences.private combinators math.order math.private accessors accessors slots.private generic.single.private compiler.units
slots.private generic.single.private compiler.units compiler.constants compiler.constants fry bootstrap.image.syntax ;
fry bootstrap.image.syntax ;
IN: bootstrap.image IN: bootstrap.image
: arch ( os cpu -- arch ) : arch ( os cpu -- arch )

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: math math.order math.parser math.functions kernel USING: math math.order math.parser math.functions kernel
sequences io accessors arrays io.streams.string splitting sequences io accessors arrays io.streams.string splitting
combinators accessors calendar calendar.format.macros present ; combinators calendar calendar.format.macros present ;
IN: calendar.format IN: calendar.format
: pad-00 ( n -- str ) number>string 2 CHAR: 0 pad-head ; : pad-00 ( n -- str ) number>string 2 CHAR: 0 pad-head ;

View File

@ -3,7 +3,7 @@
! !
! Channels - based on ideas from newsqueak ! Channels - based on ideas from newsqueak
USING: kernel sequences threads continuations USING: kernel sequences threads continuations
random math accessors random ; random math accessors ;
IN: channels IN: channels
TUPLE: channel receivers senders ; TUPLE: channel receivers senders ;

View File

@ -30,8 +30,8 @@ ARTICLE: "checksums.openssl" "OpenSSL checksums"
"An error thrown if the digest name is unrecognized:" "An error thrown if the digest name is unrecognized:"
{ $subsection unknown-digest } { $subsection unknown-digest }
"An example where we compute the SHA1 checksum of a string using the OpenSSL implementation of SHA1:" "An example where we compute the SHA1 checksum of a string using the OpenSSL implementation of SHA1:"
{ $example "USING: byte-arrays checksums checksums.openssl prettyprint ;" "\"hello world\" >byte-array openssl-sha1 checksum-bytes hex-string ." "\"2aae6c35c94fcfb415dbe95f408b9ce91ee846ed\"" } { $example "USING: byte-arrays checksums checksums.openssl ;" "\"hello world\" >byte-array openssl-sha1 checksum-bytes hex-string ." "\"2aae6c35c94fcfb415dbe95f408b9ce91ee846ed\"" }
"If we use the Factor implementation, we get the same result, just slightly slower:" "If we use the Factor implementation, we get the same result, just slightly slower:"
{ $example "USING: byte-arrays checksums checksums.sha1 prettyprint ;" "\"hello world\" >byte-array sha1 checksum-bytes hex-string ." "\"2aae6c35c94fcfb415dbe95f408b9ce91ee846ed\"" } ; { $example "USING: byte-arrays checksums checksums.sha1 ;" "\"hello world\" >byte-array sha1 checksum-bytes hex-string ." "\"2aae6c35c94fcfb415dbe95f408b9ce91ee846ed\"" } ;
ABOUT: "checksums.openssl" ABOUT: "checksums.openssl"

View File

@ -1,7 +1,7 @@
! Copyright (C) 2006, 2008 Doug Coleman. ! Copyright (C) 2006, 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: arrays combinators kernel io io.encodings.binary io.files USING: arrays combinators kernel io io.encodings.binary io.files
io.streams.byte-array math.vectors strings sequences namespaces io.streams.byte-array math.vectors strings namespaces
make math parser sequences assocs grouping vectors io.binary make math parser sequences assocs grouping vectors io.binary
hashtables math.bitwise checksums checksums.common hashtables math.bitwise checksums checksums.common
checksums.stream ; checksums.stream ;

View File

@ -2,9 +2,9 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien alien.c-types alien.strings arrays assocs USING: accessors alien alien.c-types alien.strings arrays assocs
continuations combinators compiler compiler.alien stack-checker kernel continuations combinators compiler compiler.alien stack-checker kernel
math namespaces make parser quotations sequences strings words math namespaces make quotations sequences strings words
cocoa.runtime io macros memoize io.encodings.utf8 effects libc cocoa.runtime io macros memoize io.encodings.utf8 effects libc
libc.private parser lexer init core-foundation fry generalizations libc.private lexer init core-foundation fry generalizations
specialized-arrays.direct.alien ; specialized-arrays.direct.alien ;
IN: cocoa.messages IN: cocoa.messages

View File

@ -69,6 +69,4 @@ SYMBOL: main-vocab-hook
: ignore-cli-args? ( -- ? ) : ignore-cli-args? ( -- ? )
os macosx? "run" get "ui" = and ; os macosx? "run" get "ui" = and ;
: script-mode ( -- ) ;
[ default-cli-args ] "command-line" add-init-hook [ default-cli-args ] "command-line" add-init-hook

View File

@ -1,7 +1,7 @@
! Copyright (C) 2008 Slava Pestov. ! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: kernel accessors namespaces make math sequences sets USING: kernel accessors namespaces make math sequences sets
assocs fry compiler.cfg.instructions ; assocs fry compiler.cfg compiler.cfg.instructions ;
IN: compiler.cfg.rpo IN: compiler.cfg.rpo
SYMBOL: visited SYMBOL: visited

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors kernel namespaces arrays sequences io words fry USING: accessors kernel namespaces arrays sequences io words fry
continuations vocabs assocs dlists definitions math graphs generic continuations vocabs assocs dlists definitions math graphs generic
generic.single combinators deques search-deques macros io generic.single combinators deques search-deques macros
source-files.errors stack-checker stack-checker.state source-files.errors stack-checker stack-checker.state
stack-checker.inlining stack-checker.errors combinators.short-circuit stack-checker.inlining stack-checker.errors combinators.short-circuit
compiler.errors compiler.units compiler.tree.builder compiler.errors compiler.units compiler.tree.builder

View File

@ -1,9 +1,8 @@
USING: alien alien.c-types alien.syntax compiler kernel USING: alien alien.c-types alien.syntax compiler kernel namespaces
namespaces namespaces tools.test sequences stack-checker sequences stack-checker stack-checker.errors words arrays parser
stack-checker.errors words arrays parser quotations quotations continuations effects namespaces.private io
continuations effects namespaces.private io io.streams.string io.streams.string memory system threads tools.test math accessors
memory system threads tools.test math accessors combinators combinators specialized-arrays.float alien.libraries io.pathnames
specialized-arrays.float alien.libraries io.pathnames
io.backend ; io.backend ;
IN: compiler.tests.alien IN: compiler.tests.alien

View File

@ -1,9 +1,9 @@
USING: generalizations accessors arrays compiler kernel USING: generalizations accessors arrays compiler kernel kernel.private
kernel.private math hashtables.private math.private namespaces math hashtables.private math.private namespaces sequences tools.test
sequences sequences.private tools.test namespaces.private namespaces.private slots.private sequences.private byte-arrays alien
slots.private sequences.private byte-arrays alien
alien.accessors layouts words definitions compiler.units io alien.accessors layouts words definitions compiler.units io
combinators vectors grouping make ; combinators vectors grouping make ;
QUALIFIED: namespaces.private
IN: compiler.tests.codegen IN: compiler.tests.codegen
! Originally, this file did black box testing of templating ! Originally, this file did black box testing of templating
@ -48,7 +48,7 @@ unit-test
[ 3 ] [ 3 ]
[ [
global [ 3 \ foo set ] bind global [ 3 \ foo set ] bind
\ foo [ global >n get ndrop ] compile-call \ foo [ global >n get namespaces.private:ndrop ] compile-call
] unit-test ] unit-test
: blech ( x -- ) drop ; : blech ( x -- ) drop ;
@ -62,7 +62,7 @@ unit-test
[ 3 ] [ 3 ]
[ [
global [ 3 \ foo set ] bind global [ 3 \ foo set ] bind
\ foo [ global [ get ] swap >n call ndrop ] compile-call \ foo [ global [ get ] swap >n call namespaces.private:ndrop ] compile-call
] unit-test ] unit-test
[ 3 ] [ 3 ]

View File

@ -1,10 +1,10 @@
USING: accessors arrays compiler.units kernel kernel.private math USING: accessors arrays compiler.units kernel kernel.private math
math.constants math.private sequences strings tools.test words math.constants math.private sequences strings tools.test words
continuations sequences.private hashtables.private byte-arrays continuations sequences.private hashtables.private byte-arrays
strings.private system random layouts vectors system random layouts vectors
sbufs strings.private slots.private alien math.order sbufs strings.private slots.private alien math.order
alien.accessors alien.c-types alien.syntax alien.strings alien.accessors alien.c-types alien.syntax alien.strings
namespaces libc sequences.private io.encodings.ascii namespaces libc io.encodings.ascii
classes compiler ; classes compiler ;
IN: compiler.tests.intrinsics IN: compiler.tests.intrinsics

View File

@ -16,6 +16,7 @@ compiler.tree.builder
compiler.tree.optimizer compiler.tree.optimizer
compiler.tree.combinators compiler.tree.combinators
compiler.tree.checker ; compiler.tree.checker ;
FROM: fry => _ ;
RENAME: _ match => __ RENAME: _ match => __
IN: compiler.tree.debugger IN: compiler.tree.debugger

View File

@ -1,6 +1,6 @@
! Copyright (C) 2008 Slava Pestov. ! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: arrays namespaces assocs sequences kernel generic assocs USING: arrays namespaces sequences kernel generic assocs
classes vectors accessors combinators sets classes vectors accessors combinators sets
stack-checker.state stack-checker.state
stack-checker.branches stack-checker.branches

View File

@ -322,3 +322,9 @@ C: <ro-box> ro-box
[ 0 ] [ [ 0 ] [
[ { null } declare [ 1 ] [ 2 ] if ] count-unboxed-allocations [ { null } declare [ 1 ] [ 2 ] if ] count-unboxed-allocations
] unit-test ] unit-test
! Doug found a regression
TUPLE: empty-tuple ;
[ ] [ [ empty-tuple boa layout-of ] count-unboxed-allocations drop ] unit-test

View File

@ -49,14 +49,10 @@ M: #push escape-analysis*
: slot-offset ( #call -- n/f ) : slot-offset ( #call -- n/f )
dup in-d>> dup in-d>>
[ first node-value-info class>> ] [ second node-value-info literal>> ]
[ second node-value-info literal>> ] 2bi [ first node-value-info class>> ] 2bi
dup fixnum? [ 2dup [ fixnum? ] [ tuple class<= ] bi* and [
{ over 2 >= [ drop 2 - ] [ 2drop f ] if
{ [ over tuple class<= ] [ 2 - ] }
{ [ over complex class<= ] [ 1 - ] }
[ drop f ]
} cond nip
] [ 2drop f ] if ; ] [ 2drop f ] if ;
: record-slot-call ( #call -- ) : record-slot-call ( #call -- )

View File

@ -1,7 +1,7 @@
! Copyright (C) 2008 Slava Pestov. ! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: fry namespaces sequences math math.order accessors kernel arrays USING: fry namespaces sequences math math.order accessors kernel arrays
combinators compiler.utilities assocs combinators assocs
stack-checker.backend stack-checker.backend
stack-checker.branches stack-checker.branches
stack-checker.inlining stack-checker.inlining

View File

@ -1,5 +1,5 @@
USING: accessors math math.intervals sequences classes.algebra USING: accessors math math.intervals sequences classes.algebra
math kernel tools.test compiler.tree.propagation.info arrays ; kernel tools.test compiler.tree.propagation.info arrays ;
IN: compiler.tree.propagation.info.tests IN: compiler.tree.propagation.info.tests
[ f ] [ 0.0 -0.0 eql? ] unit-test [ f ] [ 0.0 -0.0 eql? ] unit-test

View File

@ -1,6 +1,6 @@
! Copyright (C) 2004, 2008 Slava Pestov. ! Copyright (C) 2004, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: sequences accessors kernel assocs sequences USING: sequences accessors kernel assocs
compiler.tree compiler.tree
compiler.tree.propagation.copy compiler.tree.propagation.copy
compiler.tree.propagation.info ; compiler.tree.propagation.info ;

View File

@ -1,5 +1,5 @@
IN: compiler.tree.tuple-unboxing.tests IN: compiler.tree.tuple-unboxing.tests
USING: tools.test compiler.tree.tuple-unboxing compiler.tree USING: tools.test compiler.tree
compiler.tree.builder compiler.tree.recursive compiler.tree.builder compiler.tree.recursive
compiler.tree.normalization compiler.tree.propagation compiler.tree.normalization compiler.tree.propagation
compiler.tree.cleanup compiler.tree.escape-analysis compiler.tree.cleanup compiler.tree.escape-analysis

View File

@ -3,6 +3,7 @@ USING: tools.test concurrency.distributed kernel io.files
io.files.temp io.directories arrays io.sockets system io.files.temp io.directories arrays io.sockets system
combinators threads math sequences concurrency.messaging combinators threads math sequences concurrency.messaging
continuations accessors prettyprint ; continuations accessors prettyprint ;
FROM: concurrency.messaging => receive send ;
: test-node ( -- addrspec ) : test-node ( -- addrspec )
{ {

View File

@ -1,7 +1,8 @@
IN: concurrency.exchangers.tests IN: concurrency.exchangers.tests
USING: sequences tools.test concurrency.exchangers USING: tools.test concurrency.exchangers
concurrency.count-downs concurrency.promises locals kernel concurrency.count-downs concurrency.promises locals kernel
threads ; threads ;
FROM: sequences => 3append ;
:: exchanger-test ( -- string ) :: exchanger-test ( -- string )
[let | [let |

View File

@ -1,7 +1,7 @@
! Copyright (C) 2006 Chris Double. ! Copyright (C) 2006 Chris Double.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: help.syntax help.markup concurrency.messaging.private USING: help.syntax help.markup concurrency.messaging.private
threads kernel arrays quotations threads strings ; threads kernel arrays quotations strings ;
IN: concurrency.messaging IN: concurrency.messaging
HELP: send HELP: send
@ -53,7 +53,7 @@ ARTICLE: { "concurrency" "synchronous-sends" } "Synchronous sends"
{ $subsection reply-synchronous } { $subsection reply-synchronous }
"An example:" "An example:"
{ $example { $example
"USING: concurrency.messaging kernel prettyprint threads ;" "USING: concurrency.messaging threads ;"
"IN: scratchpad" "IN: scratchpad"
": pong-server ( -- )" ": pong-server ( -- )"
" receive [ \"pong\" ] dip reply-synchronous ;" " receive [ \"pong\" ] dip reply-synchronous ;"

View File

@ -1,7 +1,6 @@
! Copyright (C) 2008 Joe Groff. ! Copyright (C) 2008 Joe Groff.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: alien.c-types alien.syntax core-foundation.numbers kernel math USING: alien.c-types alien.syntax kernel math sequences ;
sequences core-foundation.numbers ;
IN: core-foundation.data IN: core-foundation.data
TYPEDEF: void* CFDataRef TYPEDEF: void* CFDataRef

View File

@ -1,6 +1,7 @@
IN: cpu.ppc.assembler.tests IN: cpu.ppc.assembler.tests
USING: cpu.ppc.assembler tools.test arrays kernel namespaces USING: cpu.ppc.assembler tools.test arrays kernel namespaces
make vocabs sequences ; make vocabs sequences ;
FROM: cpu.ppc.assembler => B ;
: test-assembler ( expected quot -- ) : test-assembler ( expected quot -- )
[ 1array ] [ [ B{ } make ] curry ] bi* unit-test ; [ 1array ] [ [ B{ } make ] curry ] bi* unit-test ;

View File

@ -4,6 +4,7 @@ USING: bootstrap.image.private kernel kernel.private namespaces
system cpu.ppc.assembler compiler.codegen.fixup compiler.units system cpu.ppc.assembler compiler.codegen.fixup compiler.units
compiler.constants math math.private layouts words compiler.constants math math.private layouts words
vocabs slots.private locals.backend ; vocabs slots.private locals.backend ;
FROM: cpu.ppc.assembler => B ;
IN: bootstrap.ppc IN: bootstrap.ppc
4 \ cell set 4 \ cell set

View File

@ -7,6 +7,7 @@ cpu.ppc.assembler cpu.ppc.assembler.backend literals compiler.cfg.registers
compiler.cfg.instructions compiler.constants compiler.codegen compiler.cfg.instructions compiler.constants compiler.codegen
compiler.codegen.fixup compiler.cfg.intrinsics compiler.codegen.fixup compiler.cfg.intrinsics
compiler.cfg.stack-frame compiler.units ; compiler.cfg.stack-frame compiler.units ;
FROM: cpu.ppc.assembler => B ;
IN: cpu.ppc IN: cpu.ppc
! PowerPC register assignments: ! PowerPC register assignments:

View File

@ -1,7 +1,8 @@
! Copyright (C) 2009 Doug Coleman. ! Copyright (C) 2009 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: kernel db.errors peg.ebnf strings sequences math USING: kernel db.errors peg.ebnf strings sequences math
combinators.short-circuit accessors math.parser quoting ; combinators.short-circuit accessors math.parser quoting
locals ;
IN: db.errors.postgresql IN: db.errors.postgresql
EBNF: parse-postgresql-sql-error EBNF: parse-postgresql-sql-error

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: concurrency.combinators db.pools db.sqlite db.tuples USING: concurrency.combinators db.pools db.sqlite db.tuples
db.types kernel math random threads tools.test db sequences db.types kernel math random threads tools.test db sequences
io prettyprint db.postgresql db.sqlite accessors io.files.temp io prettyprint db.postgresql accessors io.files.temp
namespaces fry system math.parser ; namespaces fry system math.parser ;
IN: db.tester IN: db.tester

View File

@ -1,11 +1,12 @@
! Copyright (C) 2008 Doug Coleman. ! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: io.files io.files.temp kernel tools.test db db.tuples classes USING: io.files io.files.temp kernel tools.test db db.tuples classes
db.types continuations namespaces math math.ranges db.types continuations namespaces math
prettyprint calendar sequences db.sqlite math.intervals prettyprint calendar sequences db.sqlite math.intervals
db.postgresql accessors random math.bitwise system db.postgresql accessors random math.bitwise system
math.ranges strings urls fry db.tuples.private db.private math.ranges strings urls fry db.tuples.private db.private
db.tester ; db.tester ;
FROM: math.ranges => [a,b] ;
IN: db.tuples.tests IN: db.tuples.tests
TUPLE: person the-id the-name the-number the-real TUPLE: person the-id the-name the-number the-real

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: arrays assocs classes db kernel namespaces USING: arrays assocs classes db kernel namespaces
classes.tuple words sequences slots math accessors classes.tuple words sequences slots math accessors
math.parser io prettyprint db.types continuations math.parser io prettyprint continuations
destructors mirrors sets db.types db.private fry destructors mirrors sets db.types db.private fry
combinators.short-circuit db.errors ; combinators.short-circuit db.errors ;
IN: db.tuples IN: db.tuples

View File

@ -251,8 +251,15 @@ M: already-disposed summary drop "Attempting to operate on disposed object" ;
M: no-current-vocab summary M: no-current-vocab summary
drop "Not in a vocabulary; IN: form required" ; drop "Not in a vocabulary; IN: form required" ;
M: no-word-error error. M: no-word-error summary
"No word named ``" write name>> write "'' found in current vocabulary search path" print ; name>> "No word named ``" "'' found in current vocabulary search path" surround ;
M: no-word-error error. summary print ;
M: ambiguous-use-error summary
words>> first name>> "More than one vocabulary defines a word named ``" "''" surround ;
M: ambiguous-use-error error. summary print ;
M: staging-violation summary M: staging-violation summary
drop drop

View File

@ -3,6 +3,7 @@
USING: accessors arrays io kernel math models namespaces make USING: accessors arrays io kernel math models namespaces make
sequences strings splitting combinators unicode.categories sequences strings splitting combinators unicode.categories
math.order math.ranges fry locals ; math.order math.ranges fry locals ;
FROM: models => change-model ;
IN: documents IN: documents
: +col ( loc n -- newloc ) [ first2 ] dip + 2array ; : +col ( loc n -- newloc ) [ first2 ] dip + 2array ;

View File

@ -4,7 +4,7 @@ USING: parser lexer kernel namespaces sequences definitions
io.files io.backend io.pathnames io summary continuations io.files io.backend io.pathnames io summary continuations
tools.crossref vocabs.hierarchy prettyprint source-files tools.crossref vocabs.hierarchy prettyprint source-files
source-files.errors assocs vocabs vocabs.loader splitting source-files.errors assocs vocabs vocabs.loader splitting
accessors debugger prettyprint help.topics ; accessors debugger help.topics ;
IN: editors IN: editors
TUPLE: no-edit-hook ; TUPLE: no-edit-hook ;

View File

@ -11,7 +11,10 @@ SINGLETON: gvim
HOOK: gvim-path io-backend ( -- path ) HOOK: gvim-path io-backend ( -- path )
M: gvim vim-command ( file line -- string ) M: gvim vim-command ( file line -- string )
[ gvim-path , "+" swap number>string append , , ] { } make ; [
gvim-path ,
number>string "+" prepend , ,
] { } make ;
gvim vim-editor set-global gvim vim-editor set-global

View File

@ -3,11 +3,9 @@ namespaces prettyprint editors make ;
IN: editors.macvim IN: editors.macvim
: macvim-location ( file line -- ) : macvim ( file line -- )
drop drop
[ "open" , "-a" , "MacVim", , ] { } make [ "open" , "-a" , "MacVim", , ] { } make
try-process ; run-detached drop ;
[ macvim-location ] edit-hook set-global
[ macvim ] edit-hook set-global

View File

@ -25,7 +25,7 @@ IN: editors.scite
number>string "-goto:" prepend , number>string "-goto:" prepend ,
] { } make ; ] { } make ;
: scite-location ( file line -- ) : scite ( file line -- )
scite-command run-detached drop ; scite-command run-detached drop ;
[ scite-location ] edit-hook set-global [ scite ] edit-hook set-global

View File

@ -2,9 +2,9 @@ USING: definitions io.launcher kernel math math.parser parser
namespaces prettyprint editors make ; namespaces prettyprint editors make ;
IN: editors.textedit IN: editors.textedit
: textedit-location ( file line -- ) : textedit ( file line -- )
drop drop
[ "open" , "-a" , "TextEdit", , ] { } make [ "open" , "-a" , "TextEdit", , ] { } make
try-process ; run-detached drop ;
[ textedit-location ] edit-hook set-global [ textedit ] edit-hook set-global

View File

@ -1,10 +1,9 @@
USING: definitions io.launcher kernel math math.parser parser USING: definitions io.launcher kernel math math.parser parser
namespaces prettyprint editors make ; namespaces prettyprint editors make ;
IN: editors.textmate IN: editors.textmate
: textmate-location ( file line -- ) : textmate ( file line -- )
[ "mate" , "-a" , "-l" , number>string , , ] { } make [ "mate" , "-a" , "-l" , number>string , , ] { } make
try-process ; run-detached drop ;
[ textmate-location ] edit-hook set-global [ textmate ] edit-hook set-global

View File

@ -3,7 +3,7 @@ USING: definitions editors help help.markup help.syntax io io.files
IN: editors.vim IN: editors.vim
ARTICLE: { "vim" "vim" } "Vim support" ARTICLE: { "vim" "vim" } "Vim support"
"This module makes the " { $link edit } " word work with Vim by setting the " { $link edit-hook } " global variable to call " { $link vim-location } ". The " { $link vim-path } " variable contains the name of the vim executable. The default " { $link vim-path } " is " { $snippet "\"gvim\"" } "." "This module makes the " { $link edit } " word work with Vim by setting the " { $link edit-hook } " global variable to call " { $link vim } ". The " { $link vim-path } " variable contains the name of the vim executable. The default " { $link vim-path } " is " { $snippet "\"gvim\"" } "."
$nl $nl
"If you intend to use this module regularly, it helps to have it load during stage 2 bootstrap. On Windows, place the following example " { $snippet ".factor-boot-rc" } " in the directory returned by " { $link home } ":" "If you intend to use this module regularly, it helps to have it load during stage 2 bootstrap. On Windows, place the following example " { $snippet ".factor-boot-rc" } " in the directory returned by " { $link home } ":"
{ $code { $code

View File

@ -4,7 +4,6 @@ make ;
IN: editors.vim IN: editors.vim
SYMBOL: vim-path SYMBOL: vim-path
SYMBOL: vim-editor SYMBOL: vim-editor
HOOK: vim-command vim-editor ( file line -- array ) HOOK: vim-command vim-editor ( file line -- array )
@ -12,12 +11,13 @@ SINGLETON: vim
M: vim vim-command M: vim vim-command
[ [
vim-path get , swap , "+" swap number>string append , vim-path get ,
[ , ] [ number>string "+" prepend , ] bi*
] { } make ; ] { } make ;
: vim-location ( file line -- ) : vim ( file line -- )
vim-command try-process ; vim-command run-detached drop ;
"vim" vim-path set-global "vim" vim-path set-global
[ vim-location ] edit-hook set-global [ vim ] edit-hook set-global
vim vim-editor set-global \ vim vim-editor set-global

View File

@ -2,8 +2,7 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.c-types alien.strings alien.syntax kernel USING: alien alien.c-types alien.strings alien.syntax kernel
layouts sequences system unix environment io.encodings.utf8 layouts sequences system unix environment io.encodings.utf8
unix.utilities vocabs.loader combinators alien.accessors unix.utilities vocabs.loader combinators alien.accessors ;
alien.syntax ;
IN: environment.unix IN: environment.unix
HOOK: environ os ( -- void* ) HOOK: environ os ( -- void* )

View File

@ -1,6 +1,6 @@
! Copyright (C) 2008, 2009 Slava Pestov. ! Copyright (C) 2008, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: splitting parser compiler.units kernel namespaces USING: splitting parser parser.notes compiler.units kernel namespaces
debugger io.streams.string fry combinators effects.parser ; debugger io.streams.string fry combinators effects.parser ;
IN: eval IN: eval

View File

@ -96,7 +96,7 @@ link-no-follow? off
[ "<pre><span class=\"KEYWORD3\">int</span> <span class=\"FUNCTION\">main</span><span class=\"OPERATOR\">(</span><span class=\"OPERATOR\">)</span></pre>" ] [ "<pre><span class=\"KEYWORD3\">int</span> <span class=\"FUNCTION\">main</span><span class=\"OPERATOR\">(</span><span class=\"OPERATOR\">)</span></pre>" ]
[ "[c{int main()}]" convert-farkup ] unit-test [ "[c{int main()}]" convert-farkup ] unit-test
[ "<p><img src=\"lol.jpg\" alt=\"image:lol.jpg\"/></p>" ] [ "[[image:lol.jpg]]" convert-farkup ] unit-test [ "<p><img src=\"lol.jpg\" alt=\"lol.jpg\"/></p>" ] [ "[[image:lol.jpg]]" convert-farkup ] unit-test
[ "<p><img src=\"lol.jpg\" alt=\"teh lol\"/></p>" ] [ "[[image:lol.jpg|teh lol]]" convert-farkup ] unit-test [ "<p><img src=\"lol.jpg\" alt=\"teh lol\"/></p>" ] [ "[[image:lol.jpg|teh lol]]" convert-farkup ] unit-test
[ "<p><a href=\"http://lol.com\">http://lol.com</a></p>" ] [ "[[http://lol.com]]" convert-farkup ] unit-test [ "<p><a href=\"http://lol.com\">http://lol.com</a></p>" ] [ "[[http://lol.com]]" convert-farkup ] unit-test
[ "<p><a href=\"http://lol.com\">haha</a></p>" ] [ "[[http://lol.com|haha]]" convert-farkup ] unit-test [ "<p><a href=\"http://lol.com\">haha</a></p>" ] [ "[[http://lol.com|haha]]" convert-farkup ] unit-test
@ -207,3 +207,5 @@ link-no-follow? off
[ convert-farkup drop t ] [ drop print f ] recover [ convert-farkup drop t ] [ drop print f ] recover
] all? ] all?
] unit-test ] unit-test
[ "<p><a href=\"http://foo.com/~foo\">http://foo.com/~foo</a></p>" ] [ "[[http://foo.com/~foo]]" convert-farkup ] unit-test

View File

@ -70,11 +70,15 @@ DEFER: (parse-paragraph)
{ CHAR: % inline-code } { CHAR: % inline-code }
} at ; } at ;
: or-simple-title ( url title/f quot: ( title -- title' ) -- url title' )
[ "" like dup simple-link-title ] if* ; inline
: parse-link ( string -- paragraph-list ) : parse-link ( string -- paragraph-list )
rest-slice "]]" split1-slice [ rest-slice "]]" split1-slice [
"|" split1 "|" split1
[ "" like dup simple-link-title ] unless* [ "image:" ?head ] dip swap
[ "image:" ?head ] dip swap [ image boa ] [ parse-paragraph link boa ] if [ [ ] or-simple-title image boa ]
[ [ parse-paragraph ] or-simple-title link boa ] if
] dip [ (parse-paragraph) cons ] [ 1list ] if* ; ] dip [ (parse-paragraph) cons ] [ 1list ] if* ;
: ?first ( seq -- elt ) 0 swap ?nth ; : ?first ( seq -- elt ) 0 swap ?nth ;

View File

@ -1,10 +1,10 @@
! Copyright (C) 2008 John Benediktsson ! Copyright (C) 2008 John Benediktsson
! See http://factorcode.org/license.txt for BSD license ! See http://factorcode.org/license.txt for BSD license
USING: accessors arrays ascii assocs calendar combinators fry kernel USING: accessors arrays assocs calendar combinators fry kernel
generalizations io io.encodings.ascii io.files io.streams.string generalizations io io.streams.string macros math math.functions
macros math math.functions math.parser peg.ebnf quotations math.parser peg.ebnf quotations sequences splitting strings
sequences splitting strings unicode.case vectors combinators.smart ; unicode.categories unicode.case vectors combinators.smart ;
IN: formatting IN: formatting

View File

@ -2,6 +2,7 @@ USING: calendar ftp.server io.encodings.ascii io.files
io.files.unique namespaces threads tools.test kernel io.files.unique namespaces threads tools.test kernel
io.servers.connection ftp.client accessors urls io.servers.connection ftp.client accessors urls
io.pathnames io.directories sequences fry ; io.pathnames io.directories sequences fry ;
FROM: ftp.client => ftp-get ;
IN: ftp.server.tests IN: ftp.server.tests
: test-file-contents ( -- string ) : test-file-contents ( -- string )

View File

@ -146,10 +146,10 @@ DEFER: ;FUNCTOR delimiter
} ; } ;
: push-functor-words ( -- ) : push-functor-words ( -- )
functor-words use get push ; functor-words use-words ;
: pop-functor-words ( -- ) : pop-functor-words ( -- )
functor-words use get delq ; functor-words unuse-words ;
: parse-functor-body ( -- form ) : parse-functor-body ( -- form )
push-functor-words push-functor-words

View File

@ -1,5 +1,5 @@
USING: help.markup help.syntax io.streams.string quotations USING: help.markup help.syntax io.streams.string quotations
strings calendar serialize kernel furnace.db words words.symbol strings calendar serialize furnace.db words words.symbol
kernel ; kernel ;
IN: furnace.sessions IN: furnace.sessions

View File

@ -1,7 +1,7 @@
USING: cocoa cocoa.plists core-foundation iokit iokit.hid USING: cocoa cocoa.plists core-foundation iokit iokit.hid
kernel cocoa.enumeration destructors math.parser cocoa.application kernel cocoa.enumeration destructors math.parser cocoa.application
sequences locals combinators.short-circuit threads sequences locals combinators.short-circuit threads
namespaces assocs vectors arrays combinators hints alien namespaces assocs arrays combinators hints alien
core-foundation.run-loop accessors sequences.private core-foundation.run-loop accessors sequences.private
alien.c-types math parser game-input vectors bit-arrays ; alien.c-types math parser game-input vectors bit-arrays ;
IN: game-input.iokit IN: game-input.iokit
@ -12,10 +12,11 @@ SYMBOLS: +hid-manager+ +keyboard-state+ +mouse-state+ +controller-states+ ;
iokit-game-input-backend game-input-backend set-global iokit-game-input-backend game-input-backend set-global
: hid-manager-matching ( matching-seq -- alien ) : make-hid-manager ( -- alien )
f 0 IOHIDManagerCreate f 0 IOHIDManagerCreate ;
[ swap >plist IOHIDManagerSetDeviceMatchingMultiple ]
keep ; : set-hid-manager-matching ( alien matching-seq -- )
>plist IOHIDManagerSetDeviceMatchingMultiple ;
: devices-from-hid-manager ( manager -- vector ) : devices-from-hid-manager ( manager -- vector )
[ [
@ -85,9 +86,6 @@ CONSTANT: hat-switch-matching-hash
: ?hat-switch ( device -- ? ) : ?hat-switch ( device -- ? )
hat-switch-matching-hash ?axis ; hat-switch-matching-hash ?axis ;
: hid-manager-matching-game-devices ( -- alien )
game-devices-matching-seq hid-manager-matching ;
: device-property ( device key -- value ) : device-property ( device key -- value )
<NSString> IOHIDDeviceGetProperty [ plist> ] [ f ] if* ; <NSString> IOHIDDeviceGetProperty [ plist> ] [ f ] if* ;
: element-property ( element key -- value ) : element-property ( element key -- value )
@ -288,12 +286,13 @@ M: iokit-game-input-backend reset-mouse
256 <bit-array> +keyboard-state+ set-global ; 256 <bit-array> +keyboard-state+ set-global ;
M: iokit-game-input-backend (open-game-input) M: iokit-game-input-backend (open-game-input)
hid-manager-matching-game-devices { make-hid-manager {
[ initialize-variables ] [ initialize-variables ]
[ device-matched-callback f IOHIDManagerRegisterDeviceMatchingCallback ] [ device-matched-callback f IOHIDManagerRegisterDeviceMatchingCallback ]
[ device-removed-callback f IOHIDManagerRegisterDeviceRemovalCallback ] [ device-removed-callback f IOHIDManagerRegisterDeviceRemovalCallback ]
[ device-input-callback f IOHIDManagerRegisterInputValueCallback ] [ device-input-callback f IOHIDManagerRegisterInputValueCallback ]
[ 0 IOHIDManagerOpen mach-error ] [ 0 IOHIDManagerOpen mach-error ]
[ game-devices-matching-seq set-hid-manager-matching ]
[ [
CFRunLoopGetMain CFRunLoopDefaultMode CFRunLoopGetMain CFRunLoopDefaultMode
IOHIDManagerScheduleWithRunLoop IOHIDManagerScheduleWithRunLoop

View File

@ -1,4 +1,4 @@
USING: help.markup help.syntax io kernel math namespaces parser USING: help.markup help.syntax io kernel math parser
prettyprint sequences vocabs.loader namespaces stack-checker prettyprint sequences vocabs.loader namespaces stack-checker
help command-line multiline see ; help command-line multiline see ;
IN: help.cookbook IN: help.cookbook
@ -136,7 +136,7 @@ ARTICLE: "cookbook-variables" "Dynamic variables cookbook"
} ; } ;
ARTICLE: "cookbook-vocabs" "Vocabularies cookbook" ARTICLE: "cookbook-vocabs" "Vocabularies cookbook"
"Rather than being in one flat list, words belong to vocabularies; every word is contained in exactly one. When parsing a word name, the parser searches the " { $emphasis "vocabulary search path" } ". When working at the listener, a useful set of vocabularies is already available. In a source file, all used vocabularies must be imported." "Rather than being in one flat list, words belong to vocabularies; every word is contained in exactly one. When parsing a word name, the parser searches through vocabularies. When working at the listener, a useful set of vocabularies is already available. In a source file, all used vocabularies must be imported."
$nl $nl
"For example, a source file containing the following code will print a parse error if you try loading it:" "For example, a source file containing the following code will print a parse error if you try loading it:"
{ $code "\"Hello world\" print" } { $code "\"Hello world\" print" }
@ -161,7 +161,7 @@ $nl
"You would have to place the first definition after the two others for the parser to accept the file." "You would have to place the first definition after the two others for the parser to accept the file."
{ $references { $references
{ } { }
"vocabulary-search" "word-search"
"words" "words"
"parser" "parser"
} ; } ;
@ -286,7 +286,6 @@ ARTICLE: "cookbook-pitfalls" "Pitfalls to avoid"
{ $list { $list
"Factor only makes use of one native thread, and Factor threads are scheduled co-operatively. C library calls block the entire VM." "Factor only makes use of one native thread, and Factor threads are scheduled co-operatively. C library calls block the entire VM."
"Factor does not hide anything from the programmer, all internals are exposed. It is your responsibility to avoid writing fragile code which depends too much on implementation detail." "Factor does not hide anything from the programmer, all internals are exposed. It is your responsibility to avoid writing fragile code which depends too much on implementation detail."
{ "When a source file uses two vocabularies which define words with the same name, the order of the vocabularies in the " { $link POSTPONE: USE: } " or " { $link POSTPONE: USING: } " forms is important. The " { $link POSTPONE: QUALIFIED: } " word implements qualified naming, which can be used to resolve ambiguities." }
{ "If a literal object appears in a word definition, the object itself is pushed on the stack when the word executes, not a copy. If you intend to mutate this object, you must " { $link clone } " it first. See " { $link "syntax-literals" } "." } { "If a literal object appears in a word definition, the object itself is pushed on the stack when the word executes, not a copy. If you intend to mutate this object, you must " { $link clone } " it first. See " { $link "syntax-literals" } "." }
{ "For a discussion of potential issues surrounding the " { $link f } " object, see " { $link "booleans" } "." } { "For a discussion of potential issues surrounding the " { $link f } " object, see " { $link "booleans" } "." }
{ "Factor's object system is quite flexible. Careless usage of union, mixin and predicate classes can lead to similar problems to those caused by “multiple inheritance” in other languages. In particular, it is possible to have two classes such that they have a non-empty intersection and yet neither is a subclass of the other. If a generic word defines methods on two such classes, various disambiguation rules are applied to ensure method dispatch remains deterministic, however they may not be what you expect. See " { $link "method-order" } " for details." } { "Factor's object system is quite flexible. Careless usage of union, mixin and predicate classes can lead to similar problems to those caused by “multiple inheritance” in other languages. In particular, it is possible to have two classes such that they have a non-empty intersection and yet neither is a subclass of the other. If a generic word defines methods on two such classes, various disambiguation rules are applied to ensure method dispatch remains deterministic, however they may not be what you expect. See " { $link "method-order" } " for details." }

View File

@ -248,14 +248,14 @@ ARTICLE: "handbook-language-reference" "The language"
{ $subsection "namespaces-global" } { $subsection "namespaces-global" }
{ $subsection "values" } { $subsection "values" }
{ $heading "Abstractions" } { $heading "Abstractions" }
{ $subsection "errors" } { $subsection "fry" }
{ $subsection "objects" } { $subsection "objects" }
{ $subsection "errors" }
{ $subsection "destructors" } { $subsection "destructors" }
{ $subsection "continuations" }
{ $subsection "memoize" } { $subsection "memoize" }
{ $subsection "parsing-words" } { $subsection "parsing-words" }
{ $subsection "macros" } { $subsection "macros" }
{ $subsection "fry" } { $subsection "continuations" }
{ $heading "Program organization" } { $heading "Program organization" }
{ $subsection "vocabs.loader" } { $subsection "vocabs.loader" }
"Vocabularies tagged " { $link T{ vocab-tag { name "extensions" } } } " implement various additional language abstractions." ; "Vocabularies tagged " { $link T{ vocab-tag { name "extensions" } } } " implement various additional language abstractions." ;

View File

@ -2,3 +2,5 @@ IN: help.html.tests
USING: help.html tools.test help.topics kernel ; USING: help.html tools.test help.topics kernel ;
[ ] [ "xml" >link help>html drop ] unit-test [ ] [ "xml" >link help>html drop ] unit-test
[ "article-foobar.html" ] [ "foobar" >link topic>filename ] unit-test

View File

@ -1,11 +1,13 @@
! Copyright (C) 2008, 2009 Slava Pestov. ! Copyright (C) 2008, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: io.encodings.utf8 io.encodings.ascii io.encodings.binary USING: io.encodings.utf8 io.encodings.binary
io.files io.files.temp io.directories html.streams help kernel io.files io.files.temp io.directories html.streams help kernel
assocs sequences make words accessors arrays help.topics vocabs assocs sequences make words accessors arrays help.topics vocabs
vocabs.hierarchy help.vocabs namespaces prettyprint io vocabs.hierarchy help.vocabs namespaces prettyprint io
vocabs.loader serialize fry memoize ascii unicode.case math.order vocabs.loader serialize fry memoize unicode.case math.order
sorting debugger html xml.syntax xml.writer math.parser ; sorting debugger html xml.syntax xml.writer math.parser ;
FROM: io.encodings.ascii => ascii ;
FROM: ascii => ascii? ;
IN: help.html IN: help.html
: escape-char ( ch -- ) : escape-char ( ch -- )

View File

@ -66,11 +66,12 @@ PRIVATE>
] check-something ; ] check-something ;
: check-about ( vocab -- ) : check-about ( vocab -- )
dup '[ _ vocab-help [ article drop ] when* ] check-something ; vocab-link boa dup
'[ _ vocab-help [ article drop ] when* ] check-something ;
: check-vocab ( vocab -- ) : check-vocab ( vocab -- )
"Checking " write dup write "..." print "Checking " write dup write "..." print
[ vocab check-about ] [ check-about ]
[ words [ check-word ] each ] [ words [ check-word ] each ]
[ vocab-articles get at [ check-article ] each ] [ vocab-articles get at [ check-article ] each ]
tri ; tri ;

View File

@ -5,6 +5,7 @@ hashtables namespaces make parser prettyprint sequences strings
io.styles vectors words math sorting splitting classes slots fry io.styles vectors words math sorting splitting classes slots fry
sets vocabs help.stylesheet help.topics vocabs.loader quotations sets vocabs help.stylesheet help.topics vocabs.loader quotations
combinators see present ; combinators see present ;
FROM: prettyprint.sections => with-pprint ;
IN: help.markup IN: help.markup
PREDICATE: simple-element < array PREDICATE: simple-element < array
@ -348,8 +349,6 @@ M: f ($instance)
drop drop
"Throws an error if the I/O operation fails." $errors ; "Throws an error if the I/O operation fails." $errors ;
FROM: prettyprint.private => with-pprint ;
: $prettyprinting-note ( children -- ) : $prettyprinting-note ( children -- )
drop { drop {
"This word should only be called from inside the " "This word should only be called from inside the "

View File

@ -16,4 +16,4 @@ SYNTAX: ARTICLE:
] dip remember-definition ; ] dip remember-definition ;
SYNTAX: ABOUT: SYNTAX: ABOUT:
in get vocab scan-object >>help changed-definition ; current-vocab scan-object >>help changed-definition ;

View File

@ -38,7 +38,7 @@ $nl
$nl $nl
"Now we have changed the source file, we must reload it into Factor so that we can test the new definition. To do this, simply go to the Factor listener and press " { $command tool "common" refresh-all } ". This will find any previously-loaded source files which have changed on disk, and reload them." "Now we have changed the source file, we must reload it into Factor so that we can test the new definition. To do this, simply go to the Factor listener and press " { $command tool "common" refresh-all } ". This will find any previously-loaded source files which have changed on disk, and reload them."
$nl $nl
"When you do this, you will get an error about the " { $link dup } " word not being found. This is because this word is part of the " { $vocab-link "kernel" } " vocabulary, but this vocabulary is not part of the source file's " { $link "vocabulary-search" } ". You must explicitly list dependencies in source files. This allows Factor to automatically load required vocabularies and makes larger programs easier to maintain." "When you do this, you will get an error about the " { $link dup } " word not being found. This is because this word is part of the " { $vocab-link "kernel" } " vocabulary, but this vocabulary is not part of the source file's " { $link "word-search" } ". You must explicitly list dependencies in source files. This allows Factor to automatically load required vocabularies and makes larger programs easier to maintain."
$nl $nl
"To add the word to the search path, first convince yourself that this word is in the " { $vocab-link "kernel" } " vocabulary. Enter " { $snippet "dup" } " in the listener's input area, and press " { $operation com-browse } ". This will open the documentation browser tool, viewing the help for the " { $link dup } " word. One of the subheadings in the help article will mention the word's vocabulary." "To add the word to the search path, first convince yourself that this word is in the " { $vocab-link "kernel" } " vocabulary. Enter " { $snippet "dup" } " in the listener's input area, and press " { $operation com-browse } ". This will open the documentation browser tool, viewing the help for the " { $link dup } " word. One of the subheadings in the help article will mention the word's vocabulary."
$nl $nl

View File

@ -3,6 +3,7 @@ USING: tools.test kernel io.streams.string
io.streams.null accessors inspector html.streams io.streams.null accessors inspector html.streams
html.components html.forms namespaces html.components html.forms namespaces
xml.writer ; xml.writer ;
FROM: html.components => inspector ;
[ ] [ begin-form ] unit-test [ ] [ begin-form ] unit-test

View File

@ -1,6 +1,7 @@
IN: html.forms.tests IN: html.forms.tests
USING: kernel sequences tools.test assocs html.forms validators accessors USING: kernel sequences tools.test assocs html.forms validators accessors
namespaces ; namespaces ;
FROM: html.forms => values ;
: with-validation ( quot -- messages ) : with-validation ( quot -- messages )
[ [

View File

@ -1,6 +1,6 @@
USING: html.streams html.streams.private accessors io USING: html.streams html.streams.private accessors io
io.streams.string io.styles kernel namespaces tools.test io.streams.string io.styles kernel namespaces tools.test
xml.writer sbufs sequences inspector colors xml.writer sbufs sequences inspector colors xml.writer
classes.predicate prettyprint ; classes.predicate prettyprint ;
IN: html.streams.tests IN: html.streams.tests

View File

@ -1,8 +1,9 @@
IN: html.templates.chloe IN: html.templates.chloe
USING: xml.data help.markup help.syntax html.components html.forms USING: help.markup help.syntax html.components html.forms
html.templates html.templates.chloe.syntax html.templates html.templates.chloe.syntax
html.templates.chloe.compiler html.templates.chloe.components html.templates.chloe.compiler html.templates.chloe.components
math strings quotations namespaces ; math strings quotations namespaces ;
FROM: xml.data => tag ;
HELP: <chloe> HELP: <chloe>
{ $values { "path" "a pathname string without the trailing " { $snippet ".xml" } " extension" } { "chloe" chloe } } { $values { "path" "a pathname string without the trailing " { $snippet ".xml" } " extension" } { "chloe" chloe } }

View File

@ -1,7 +1,7 @@
USING: html.templates html.templates.chloe USING: html.templates html.templates.chloe
tools.test io.streams.string kernel sequences ascii boxes tools.test io.streams.string kernel sequences ascii boxes
namespaces xml html.components html.forms namespaces xml html.components html.forms
splitting unicode.categories furnace accessors splitting furnace accessors
html.templates.chloe.compiler ; html.templates.chloe.compiler ;
IN: html.templates.chloe.tests IN: html.templates.chloe.tests

View File

@ -1,11 +1,11 @@
! Copyright (C) 2008 Slava Pestov. ! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors kernel sequences combinators kernel fry USING: accessors kernel sequences combinators fry
namespaces make classes.tuple assocs splitting words arrays io namespaces make classes.tuple assocs splitting words arrays io
io.files io.files.info io.encodings.utf8 io.streams.string io.files io.files.info io.encodings.utf8 io.streams.string
unicode.case mirrors math urls present multiline quotations xml unicode.case mirrors math urls present multiline quotations xml
logging logging
xml.data xml.writer xml.syntax strings xml.writer xml.syntax strings
html.forms html.forms
html html
html.components html.components

View File

@ -1,13 +1,11 @@
! Copyright (C) 2008 Slava Pestov. ! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
IN: html.templates.chloe.syntax USING: accessors sequences combinators kernel namespaces classes.tuple
USING: accessors kernel sequences combinators kernel namespaces assocs splitting words arrays memoize parser lexer io io.files
classes.tuple assocs splitting words arrays memoize parser lexer io.encodings.utf8 io.streams.string unicode.case mirrors fry math urls
io io.files io.encodings.utf8 io.streams.string multiline xml xml.data xml.writer xml.syntax html.components
unicode.case mirrors fry math urls
multiline xml xml.data xml.writer xml.syntax
html.components
html.templates ; html.templates ;
IN: html.templates.chloe.syntax
SYMBOL: tags SYMBOL: tags

View File

@ -3,7 +3,7 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: continuations sequences kernel namespaces debugger USING: continuations sequences kernel namespaces debugger
combinators math quotations generic strings splitting accessors combinators math quotations generic strings splitting accessors
assocs fry vocabs.parser parser lexer io io.files assocs fry vocabs.parser parser parser.notes lexer io io.files
io.streams.string io.encodings.utf8 html.templates ; io.streams.string io.encodings.utf8 html.templates ;
IN: html.templates.fhtml IN: html.templates.fhtml
@ -60,7 +60,7 @@ SYNTAX: %> lexer get parse-%> ;
[ [
"quiet" on "quiet" on
parser-notes off parser-notes off
"html.templates.fhtml" use+ "html.templates.fhtml" use-vocab
string-lines parse-template-lines string-lines parse-template-lines
] with-file-vocabs ; ] with-file-vocabs ;

View File

@ -1,5 +1,5 @@
USING: http help.markup help.syntax io.pathnames io.streams.string USING: http help.markup help.syntax io.pathnames io.streams.string
io.encodings.8-bit io.encodings.binary kernel strings urls io.encodings.8-bit io.encodings.binary kernel urls
urls.encoding byte-arrays strings assocs sequences destructors urls.encoding byte-arrays strings assocs sequences destructors
http.client.post-data.private ; http.client.post-data.private ;
IN: http.client IN: http.client

View File

@ -1,6 +1,6 @@
! Copyright (C) 2005, 2009 Slava Pestov. ! Copyright (C) 2005, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs kernel math math.parser namespaces make USING: assocs kernel math math.parser namespaces make
sequences strings splitting calendar continuations accessors vectors sequences strings splitting calendar continuations accessors vectors
math.order hashtables byte-arrays destructors math.order hashtables byte-arrays destructors
io io.sockets io.streams.string io.files io.timeouts io io.sockets io.streams.string io.files io.timeouts

View File

@ -173,10 +173,10 @@ Set-Cookie: oo="bar; a=b"; comment="your mom"; httponly=yes
] unit-test ] unit-test
! Live-fire exercise ! Live-fire exercise
USING: http.server http.server.static furnace.sessions furnace.alloy USING: http.server.static furnace.sessions furnace.alloy
furnace.actions furnace.auth furnace.auth.login furnace.db http.client furnace.actions furnace.auth furnace.auth.login furnace.db
io.servers.connection io.files io.files.temp io.directories io io.encodings.ascii io.servers.connection io.files io.files.temp io.directories io
accessors namespaces threads threads
http.server.responses http.server.redirection furnace.redirection http.server.responses http.server.redirection furnace.redirection
http.server.dispatchers db.tuples ; http.server.dispatchers db.tuples ;

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: combinators.short-circuit math math.order math.parser USING: combinators.short-circuit math math.order math.parser
kernel sequences sequences.deep peg peg.parsers assocs arrays kernel sequences sequences.deep peg peg.parsers assocs arrays
hashtables strings unicode.case namespaces make ascii ; hashtables strings namespaces make ascii ;
IN: http.parsers IN: http.parsers
: except ( quot -- parser ) : except ( quot -- parser )

View File

@ -17,7 +17,6 @@ io.servers.connection
io.timeouts io.timeouts
io.crlf io.crlf
fry logging logging.insomniac calendar urls urls.encoding fry logging logging.insomniac calendar urls urls.encoding
mime.multipart
unicode.categories unicode.categories
http http
http.parsers http.parsers
@ -27,6 +26,7 @@ html.templates
html.streams html.streams
html html
xml.writer ; xml.writer ;
FROM: mime.multipart => parse-multipart ;
IN: http.server IN: http.server
: check-absolute ( url -- url ) : check-absolute ( url -- url )
@ -283,8 +283,6 @@ M: http-server handle-client*
: http-insomniac ( -- ) : http-insomniac ( -- )
"http.server" { "httpd-hit" } schedule-insomniac ; "http.server" { "httpd-hit" } schedule-insomniac ;
USE: vocabs.loader
"http.server.filters" require "http.server.filters" require
"http.server.dispatchers" require "http.server.dispatchers" require
"http.server.redirection" require "http.server.redirection" require

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: constructors kernel splitting unicode.case combinators USING: constructors kernel splitting unicode.case combinators
accessors images.bitmap images.tiff images io.pathnames accessors images.bitmap images.tiff images io.pathnames
images.jpeg images.png ; images.png ;
IN: images.loader IN: images.loader
ERROR: unknown-image-extension extension ; ERROR: unknown-image-extension extension ;
@ -12,8 +12,8 @@ ERROR: unknown-image-extension extension ;
{ "bmp" [ bitmap-image ] } { "bmp" [ bitmap-image ] }
{ "tif" [ tiff-image ] } { "tif" [ tiff-image ] }
{ "tiff" [ tiff-image ] } { "tiff" [ tiff-image ] }
{ "jpg" [ jpeg-image ] } ! { "jpg" [ jpeg-image ] }
{ "jpeg" [ jpeg-image ] } ! { "jpeg" [ jpeg-image ] }
{ "png" [ png-image ] } { "png" [ png-image ] }
[ unknown-image-extension ] [ unknown-image-extension ]
} case ; } case ;

View File

@ -1,7 +1,7 @@
! Copyright (C) 2009 Slava Pestov. ! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: sequences kernel math grouping fry columns locals accessors USING: sequences kernel math grouping fry columns locals accessors
images math math.vectors arrays ; images math.vectors arrays ;
IN: images.tesselation IN: images.tesselation
: group-rows ( bitmap bitmap-dim -- rows ) : group-rows ( bitmap bitmap-dim -- rows )

View File

@ -1,6 +1,6 @@
! Copyright (C) 2008, 2009 Slava Pestov. ! Copyright (C) 2008, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: io kernel macros make multiline namespaces parser USING: io kernel macros make multiline namespaces vocabs.parser
present sequences strings splitting fry accessors ; present sequences strings splitting fry accessors ;
IN: interpolate IN: interpolate

View File

@ -1,7 +1,7 @@
! Copyright (C) 2007, 2009 Daniel Ehrenberg. ! Copyright (C) 2007, 2009 Daniel Ehrenberg.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors kernel words summary slots quotations USING: accessors kernel words summary slots quotations
sequences assocs math arrays stack-checker effects generalizations sequences assocs math arrays stack-checker effects
continuations debugger classes.tuple namespaces make vectors continuations debugger classes.tuple namespaces make vectors
bit-arrays byte-arrays strings sbufs math.functions macros bit-arrays byte-arrays strings sbufs math.functions macros
sequences.private combinators mirrors splitting combinators.smart sequences.private combinators mirrors splitting combinators.smart

View File

@ -3,7 +3,7 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien alien.accessors alien.c-types USING: accessors alien alien.accessors alien.c-types
alien.syntax kernel libc math sequences byte-arrays strings alien.syntax kernel libc math sequences byte-arrays strings
hints accessors math.order destructors combinators ; hints math.order destructors combinators ;
IN: io.buffers IN: io.buffers
TUPLE: buffer TUPLE: buffer

View File

@ -2,8 +2,9 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: xml xml.data kernel io io.encodings interval-maps splitting fry USING: xml xml.data kernel io io.encodings interval-maps splitting fry
math.parser sequences combinators assocs locals accessors math arrays math.parser sequences combinators assocs locals accessors math arrays
byte-arrays values io.encodings.ascii ascii io.files biassocs byte-arrays values ascii io.files biassocs math.order
math.order combinators.short-circuit io.binary io.encodings.iana ; combinators.short-circuit io.binary io.encodings.iana ;
FROM: io.encodings.ascii => ascii ;
IN: io.encodings.gb18030 IN: io.encodings.gb18030
SINGLETON: gb18030 SINGLETON: gb18030

View File

@ -1,4 +1,4 @@
USING: io.files.info io.pathnames io.encodings.utf8 io.files USING: io.files.info io.encodings.utf8 io.files
io.directories kernel io.pathnames accessors tools.test io.directories kernel io.pathnames accessors tools.test
sequences io.files.temp ; sequences io.files.temp ;
IN: io.files.info.tests IN: io.files.info.tests

View File

@ -6,6 +6,7 @@ io.files.unix kernel math.order namespaces sequences sorting
system unix unix.statfs.linux unix.statvfs.linux io.files.links system unix unix.statfs.linux unix.statvfs.linux io.files.links
specialized-arrays.direct.uint arrays io.files.info.unix assocs specialized-arrays.direct.uint arrays io.files.info.unix assocs
io.pathnames unix.types ; io.pathnames unix.types ;
FROM: csv => delimiter ;
IN: io.files.info.unix.linux IN: io.files.info.unix.linux
TUPLE: linux-file-system-info < unix-file-system-info TUPLE: linux-file-system-info < unix-file-system-info

View File

@ -4,13 +4,10 @@ USING: accessors alien.c-types arrays assocs combinators
continuations environment io io.backend io.backend.unix continuations environment io io.backend io.backend.unix
io.files io.files.private io.files.unix io.launcher io.files io.files.private io.files.unix io.launcher
io.launcher.unix.parser io.pathnames io.ports kernel math io.launcher.unix.parser io.pathnames io.ports kernel math
namespaces sequences strings system threads unix unix namespaces sequences strings system threads unix
unix.process ; unix.process ;
IN: io.launcher.unix IN: io.launcher.unix
! Search unix first
USE: unix
: get-arguments ( process -- seq ) : get-arguments ( process -- seq )
command>> dup string? [ tokenize-command ] when ; command>> dup string? [ tokenize-command ] when ;

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: continuations destructors io.files io.files.info USING: continuations destructors io.files io.files.info
io.backend kernel quotations system alien alien.accessors io.backend kernel quotations system alien alien.accessors
accessors system vocabs.loader combinators alien.c-types accessors vocabs.loader combinators alien.c-types
math ; math ;
IN: io.mmap IN: io.mmap

View File

@ -1,7 +1,7 @@
! Copyright (C) 2008 Slava Pestov. ! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: kernel io.backend io.monitors io.monitors.recursive USING: kernel io.backend io.monitors io.monitors.recursive
io.files io.pathnames io.buffers io.monitors io.ports io.timeouts io.files io.pathnames io.buffers io.ports io.timeouts
io.backend.unix io.encodings.utf8 unix.linux.inotify assocs io.backend.unix io.encodings.utf8 unix.linux.inotify assocs
namespaces make threads continuations init math math.bitwise namespaces make threads continuations init math math.bitwise
sets alien alien.strings alien.c-types vocabs.loader accessors sets alien alien.strings alien.c-types vocabs.loader accessors

View File

@ -7,6 +7,7 @@ openssl.libcrypto openssl.libssl io io.files io.ports
io.backend.unix io.sockets.unix io.encodings.ascii io.buffers io.backend.unix io.sockets.unix io.encodings.ascii io.buffers
io.sockets io.sockets.secure io.sockets.secure.openssl io.sockets io.sockets.secure io.sockets.secure.openssl
io.timeouts system summary fry ; io.timeouts system summary fry ;
FROM: io.ports => shutdown ;
IN: io.sockets.secure.unix IN: io.sockets.secure.unix
M: ssl-handle handle-fd file>> handle-fd ; M: ssl-handle handle-fd file>> handle-fd ;

View File

@ -1,18 +1,17 @@
! Copyright (C) 2007, 2008 Slava Pestov, Doug Coleman, ! Copyright (C) 2007, 2008 Slava Pestov, Doug Coleman,
! Daniel Ehrenberg. ! Daniel Ehrenberg.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: generic kernel io.backend namespaces continuations USING: generic kernel io.backend namespaces continuations sequences
sequences arrays io.encodings io.ports io.streams.duplex arrays io.encodings io.ports io.streams.duplex io.encodings.ascii
io.encodings.ascii alien.strings io.binary accessors destructors alien.strings io.binary accessors destructors classes byte-arrays
classes byte-arrays system combinators parser parser alien.c-types math.parser splitting grouping math assocs
alien.c-types math.parser splitting grouping math assocs summary summary system vocabs.loader combinators present fry vocabs.parser ;
system vocabs.loader combinators present fry vocabs.parser ;
IN: io.sockets IN: io.sockets
<< { << {
{ [ os windows? ] [ "windows.winsock" ] } { [ os windows? ] [ "windows.winsock" ] }
{ [ os unix? ] [ "unix" ] } { [ os unix? ] [ "unix" ] }
} cond use+ >> } cond use-vocab >>
! Addressing ! Addressing
GENERIC: protocol-family ( addrspec -- af ) GENERIC: protocol-family ( addrspec -- af )

View File

@ -1,13 +1,13 @@
! Copyright (C) 2004, 2008 Slava Pestov, Ivan Tikhonov. ! Copyright (C) 2004, 2008 Slava Pestov, Ivan Tikhonov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.c-types alien.strings generic kernel math USING: alien alien.c-types alien.strings generic kernel math threads
namespaces threads sequences byte-arrays io.ports sequences byte-arrays io.binary io.backend.unix io.streams.duplex
io.binary io.backend.unix io.streams.duplex io.backend io.pathnames io.files.private io.encodings.utf8 math.parser
io.backend io.ports io.pathnames io.files.private continuations libc combinators system accessors destructors unix
io.encodings.utf8 math.parser continuations libc combinators locals init ;
system accessors destructors unix locals init ;
EXCLUDE: io => read write close ; EXCLUDE: namespaces => bind ;
EXCLUDE: io => read write ;
EXCLUDE: io.sockets => accept ; EXCLUDE: io.sockets => accept ;
IN: io.sockets.unix IN: io.sockets.unix

2
basis/io/sockets/windows/nt/nt.factor Normal file → Executable file
View File

@ -1,6 +1,6 @@
USING: alien alien.accessors alien.c-types byte-arrays USING: alien alien.accessors alien.c-types byte-arrays
continuations destructors io.ports io.timeouts io.sockets continuations destructors io.ports io.timeouts io.sockets
io.sockets io namespaces io.streams.duplex io.backend.windows io namespaces io.streams.duplex io.backend.windows
io.sockets.windows io.backend.windows.nt windows.winsock kernel io.sockets.windows io.backend.windows.nt windows.winsock kernel
libc math sequences threads system combinators accessors ; libc math sequences threads system combinators accessors ;
IN: io.sockets.windows.nt IN: io.sockets.windows.nt

View File

@ -15,8 +15,6 @@ SYNTAX: hello "Hi" print ;
] with-file-vocabs ] with-file-vocabs
[ [
"debugger" use+
[ [ \ + 1 2 3 4 ] ] [ [ \ + 1 2 3 4 ] ]
[ [
[ [

View File

@ -10,7 +10,7 @@ IN: listener
GENERIC: stream-read-quot ( stream -- quot/f ) GENERIC: stream-read-quot ( stream -- quot/f )
: parse-lines-interactive ( lines -- quot/f ) : parse-lines-interactive ( lines -- quot/f )
[ parse-lines in get ] with-compilation-unit in set ; [ parse-lines ] with-compilation-unit ;
: read-quot-step ( lines -- quot/f ) : read-quot-step ( lines -- quot/f )
[ parse-lines-interactive ] [ [ parse-lines-interactive ] [
@ -98,7 +98,7 @@ t error-summary? set-global
] [ drop ] if ; ] [ drop ] if ;
: prompt. ( -- ) : prompt. ( -- )
in get auto-use? get [ " - auto" append ] when "( " " )" surround current-vocab name>> auto-use? get [ " - auto" append ] when "( " " )" surround
H{ { background T{ rgba f 1 0.7 0.7 1 } } } format bl flush ; H{ { background T{ rgba f 1 0.7 0.7 1 } } } format bl flush ;
:: (listener) ( datastack -- ) :: (listener) ( datastack -- )

View File

@ -1,4 +1,4 @@
USING: lists.lazy.examples lists.lazy tools.test ; USING: lists.lazy.examples lists.lazy lists tools.test ;
IN: lists.lazy.examples.tests IN: lists.lazy.examples.tests
[ { 1 3 5 7 } ] [ 4 odds ltake list>array ] unit-test [ { 1 3 5 7 } ] [ 4 odds ltake list>array ] unit-test

View File

@ -2,7 +2,7 @@
! Copyright (C) 2004 Chris Double. ! Copyright (C) 2004 Chris Double.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: lists.lazy math kernel sequences quotations ; USING: lists lists.lazy math kernel sequences quotations ;
IN: lists.lazy.examples IN: lists.lazy.examples
: naturals ( -- list ) 0 lfrom ; : naturals ( -- list ) 0 lfrom ;

View File

@ -14,7 +14,7 @@ ARTICLE: "lists.lazy" "Lazy lists"
ARTICLE: { "lists.lazy" "combinators" } "Combinators for manipulating lazy lists" ARTICLE: { "lists.lazy" "combinators" } "Combinators for manipulating lazy lists"
"The following combinators create lazy lists from other lazy lists:" "The following combinators create lazy lists from other lazy lists:"
{ $subsection lmap } { $subsection lazy-map }
{ $subsection lfilter } { $subsection lfilter }
{ $subsection luntil } { $subsection luntil }
{ $subsection lwhile } { $subsection lwhile }
@ -93,22 +93,12 @@ HELP: luntil
{ $values { "list" "a cons object" } { "quot" { $quotation "( X -- ? )" } } { "result" "resulting cons object" } } { $values { "list" "a cons object" } { "quot" { $quotation "( X -- ? )" } } { "result" "resulting cons object" } }
{ $description "Outputs a lazy list containing the first items in the list until after " { $snippet "quot" } " evaluates to t. No evaluation of the list elements occurs initially but a " { $link <lazy-while> } " object is returned with conforms to the list protocol. Calling " { $link car } ", " { $link cdr } " or " { $link nil? } " on this will evaluate elements as required." } ; { $description "Outputs a lazy list containing the first items in the list until after " { $snippet "quot" } " evaluates to t. No evaluation of the list elements occurs initially but a " { $link <lazy-while> } " object is returned with conforms to the list protocol. Calling " { $link car } ", " { $link cdr } " or " { $link nil? } " on this will evaluate elements as required." } ;
HELP: list>vector
{ $values { "list" "a cons object" } { "vector" "the list converted to a vector" } }
{ $description "Convert a list to a vector. If the list is a lazy infinite list then this will enter an infinite loop." }
{ $see-also list>array } ;
HELP: list>array
{ $values { "list" "a cons object" } { "array" "the list converted to an array" } }
{ $description "Convert a list to an array. If the list is a lazy infinite list then this will enter an infinite loop." }
{ $see-also list>vector } ;
HELP: lappend HELP: lappend
{ $values { "list1" "a cons object" } { "list2" "a cons object" } { "result" "a lazy list of list2 appended to list1" } } { $values { "list1" "a cons object" } { "list2" "a cons object" } { "result" "a lazy list of list2 appended to list1" } }
{ $description "Perform a similar functionality to that of the " { $link append } " word, but in a lazy manner. No evaluation of the list elements occurs initially but a " { $link <lazy-append> } " object is returned which conforms to the list protocol. Calling " { $link car } ", " { $link cdr } " or " { $link nil? } " on this will evaluate elements as required. Successive calls to " { $link cdr } " will iterate through list1, followed by list2." } ; { $description "Perform a similar functionality to that of the " { $link append } " word, but in a lazy manner. No evaluation of the list elements occurs initially but a " { $link <lazy-append> } " object is returned which conforms to the list protocol. Calling " { $link car } ", " { $link cdr } " or " { $link nil? } " on this will evaluate elements as required. Successive calls to " { $link cdr } " will iterate through list1, followed by list2." } ;
HELP: lfrom-by HELP: lfrom-by
{ $values { "n" "an integer" } { "quot" { $quotation "( -- int )" } } { "lazy-from-by" "a lazy list of integers" } } { $values { "n" "an integer" } { "quot" { $quotation "( -- n )" } } { "lazy-from-by" "a lazy list of integers" } }
{ $description "Return an infinite lazy list of values starting from n, with each successive value being the result of applying quot to n." } ; { $description "Return an infinite lazy list of values starting from n, with each successive value being the result of applying quot to n." } ;
HELP: lfrom HELP: lfrom
@ -117,7 +107,7 @@ HELP: lfrom
HELP: seq>list HELP: seq>list
{ $values { "index" "an integer 0 or greater" } { "seq" "a sequence" } { "list" "a list" } } { $values { "index" "an integer 0 or greater" } { "seq" "a sequence" } { "list" "a list" } }
{ $description "Convert the sequence into a list, starting from the 'index' offset into the sequence." } { $description "Convert the sequence into a list, starting from " { $snippet "index" } "." }
{ $see-also >list } ; { $see-also >list } ;
HELP: >list HELP: >list
@ -154,7 +144,7 @@ HELP: lmerge
{ $values { "list1" "a list" } { "list2" "a list" } { "result" "lazy list merging list1 and list2" } } { $values { "list1" "a list" } { "list2" "a list" } { "result" "lazy list merging list1 and list2" } }
{ $description "Return the result of merging the two lists in a lazy manner." } { $description "Return the result of merging the two lists in a lazy manner." }
{ $examples { $examples
{ $example "USING: lists.lazy prettyprint ;" "{ 1 2 3 } >list { 4 5 6 } >list lmerge list>array ." "{ 1 4 2 5 3 6 }" } { $example "USING: lists lists.lazy prettyprint ;" "{ 1 2 3 } >list { 4 5 6 } >list lmerge list>array ." "{ 1 4 2 5 3 6 }" }
} ; } ;
HELP: lcontents HELP: lcontents

View File

@ -178,12 +178,6 @@ M: lazy-filter nil? ( lazy-filter -- bool )
] if ] if
] if ; ] if ;
: list>vector ( list -- vector )
[ [ , ] leach ] V{ } make ;
: list>array ( list -- array )
[ [ , ] leach ] { } make ;
TUPLE: lazy-append list1 list2 ; TUPLE: lazy-append list1 list2 ;
C: <lazy-append> lazy-append C: <lazy-append> lazy-append

View File

@ -14,7 +14,7 @@ ARTICLE: "lists" "Lists"
{ $vocab-subsection "Lazy lists" "lists.lazy" } ; { $vocab-subsection "Lazy lists" "lists.lazy" } ;
ARTICLE: { "lists" "protocol" } "The list protocol" ARTICLE: { "lists" "protocol" } "The list protocol"
"Lists are instances of a mixin class" "Lists are instances of a mixin class:"
{ $subsection list } { $subsection list }
"Instances of the mixin must implement the following words:" "Instances of the mixin must implement the following words:"
{ $subsection car } { $subsection car }
@ -25,8 +25,7 @@ ARTICLE: { "lists" "strict" } "Constructing strict lists"
"Strict lists are simply cons cells where the car and cdr have already been evaluated. These are the lists of Lisp. To construct a strict list, the following words are provided:" "Strict lists are simply cons cells where the car and cdr have already been evaluated. These are the lists of Lisp. To construct a strict list, the following words are provided:"
{ $subsection cons } { $subsection cons }
{ $subsection swons } { $subsection swons }
{ $subsection sequence>cons } { $subsection sequence>list }
{ $subsection deep-sequence>cons }
{ $subsection 1list } { $subsection 1list }
{ $subsection 2list } { $subsection 2list }
{ $subsection 3list } ; { $subsection 3list } ;
@ -38,7 +37,6 @@ ARTICLE: { "lists" "combinators" } "Combinators for lists"
{ $subsection foldl } { $subsection foldl }
{ $subsection foldr } { $subsection foldr }
{ $subsection lmap>array } { $subsection lmap>array }
{ $subsection lmap-as }
{ $subsection traverse } ; { $subsection traverse } ;
ARTICLE: { "lists" "manipulation" } "Manipulating lists" ARTICLE: { "lists" "manipulation" } "Manipulating lists"
@ -54,21 +52,21 @@ ARTICLE: { "lists" "manipulation" } "Manipulating lists"
{ $subsection lcut } ; { $subsection lcut } ;
HELP: cons HELP: cons
{ $values { "car" "the head of the list cell" } { "cdr" "the tail of the list cell" } { "cons" "a cons object" } } { $values { "car" "the head of the list cell" } { "cdr" "the tail of the list cell" } { "cons" list } }
{ $description "Constructs a cons cell." } ; { $description "Constructs a cons cell." } ;
HELP: swons HELP: swons
{ $values { "cdr" "the tail of the list cell" } { "car" "the head of the list cell" } { "cons" "a cons object" } } { $values { "cdr" "the tail of the list cell" } { "car" "the head of the list cell" } { "cons" list } }
{ $description "Constructs a cons cell." } ; { $description "Constructs a cons cell." } ;
{ cons swons uncons unswons } related-words { cons swons uncons unswons } related-words
HELP: car HELP: car
{ $values { "cons" "a cons object" } { "car" "the first item in the list" } } { $values { "cons" list } { "car" "the first item in the list" } }
{ $description "Returns the first item in the list." } ; { $description "Returns the first item in the list." } ;
HELP: cdr HELP: cdr
{ $values { "cons" "a cons object" } { "cdr" "a cons object" } } { $values { "cons" list } { "cdr" list } }
{ $description "Returns the tail of the list." } ; { $description "Returns the tail of the list." } ;
{ car cdr } related-words { car cdr } related-words
@ -86,51 +84,51 @@ HELP: nil?
{ 1list 2list 3list } related-words { 1list 2list 3list } related-words
HELP: 1list HELP: 1list
{ $values { "obj" "an object" } { "cons" "a cons object" } } { $values { "obj" "an object" } { "cons" list } }
{ $description "Create a list with 1 element." } ; { $description "Create a list with 1 element." } ;
HELP: 2list HELP: 2list
{ $values { "a" "an object" } { "b" "an object" } { "cons" "a cons object" } } { $values { "a" "an object" } { "b" "an object" } { "cons" list } }
{ $description "Create a list with 2 elements." } ; { $description "Create a list with 2 elements." } ;
HELP: 3list HELP: 3list
{ $values { "a" "an object" } { "b" "an object" } { "c" "an object" } { "cons" "a cons object" } } { $values { "a" "an object" } { "b" "an object" } { "c" "an object" } { "cons" list } }
{ $description "Create a list with 3 elements." } ; { $description "Create a list with 3 elements." } ;
HELP: lnth HELP: lnth
{ $values { "n" "an integer index" } { "list" "a cons object" } { "elt" "the element at the nth index" } } { $values { "n" "an integer index" } { "list" list } { "elt" "the element at the nth index" } }
{ $description "Outputs the nth element of the list." } { $description "Outputs the nth element of the list." }
{ $see-also llength cons car cdr } ; { $see-also llength cons car cdr } ;
HELP: llength HELP: llength
{ $values { "list" "a cons object" } { "n" "a non-negative integer" } } { $values { "list" list } { "n" "a non-negative integer" } }
{ $description "Outputs the length of the list. This should not be called on an infinite list." } { $description "Outputs the length of the list. This should not be called on an infinite list." }
{ $see-also lnth cons car cdr } ; { $see-also lnth cons car cdr } ;
HELP: uncons HELP: uncons
{ $values { "cons" "a cons object" } { "car" "the head of the list" } { "cdr" "the tail of the list" } } { $values { "cons" list } { "car" "the head of the list" } { "cdr" "the tail of the list" } }
{ $description "Put the head and tail of the list on the stack." } ; { $description "Put the head and tail of the list on the stack." } ;
HELP: unswons HELP: unswons
{ $values { "cons" "a cons object" } { "car" "the head of the list" } { "cdr" "the tail of the list" } } { $values { "cons" list } { "car" "the head of the list" } { "cdr" "the tail of the list" } }
{ $description "Put the head and tail of the list on the stack." } ; { $description "Put the head and tail of the list on the stack." } ;
{ leach foldl lmap>array } related-words { leach foldl lmap>array } related-words
HELP: leach HELP: leach
{ $values { "list" "a cons object" } { "quot" { $quotation "( obj -- )" } } } { $values { "list" list } { "quot" { $quotation "( obj -- )" } } }
{ $description "Call the quotation for each item in the list." } ; { $description "Call the quotation for each item in the list." } ;
HELP: foldl HELP: foldl
{ $values { "list" "a cons object" } { "identity" "an object" } { "quot" { $quotation "( prev elt -- next )" } } { "result" "the final result" } } { $values { "list" list } { "identity" "an object" } { "quot" { $quotation "( prev elt -- next )" } } { "result" "the final result" } }
{ $description "Combines successive elements of the list (in a left-assocative order) using a binary operation and outputs the final result." } ; { $description "Combines successive elements of the list (in a left-assocative order) using a binary operation and outputs the final result." } ;
HELP: foldr HELP: foldr
{ $values { "list" "a cons object" } { "identity" "an object" } { "quot" { $quotation "( prev elt -- next )" } } { "result" "the final result" } } { $values { "list" list } { "identity" "an object" } { "quot" { $quotation "( prev elt -- next )" } } { "result" "the final result" } }
{ $description "Combines successive elements of the list (in a right-assocative order) using a binary operation, and outputs the final result." } ; { $description "Combines successive elements of the list (in a right-assocative order) using a binary operation, and outputs the final result." } ;
HELP: lmap HELP: lmap
{ $values { "list" "a cons object" } { "quot" { $quotation "( old -- new )" } } { "result" "the final result" } } { $values { "list" list } { "quot" { $quotation "( old -- new )" } } { "result" "the final result" } }
{ $description "Applies the quotation to each element of the list in order, collecting the new elements into a new list." } ; { $description "Applies the quotation to each element of the list in order, collecting the new elements into a new list." } ;
HELP: lreverse HELP: lreverse
@ -138,23 +136,11 @@ HELP: lreverse
{ $description "Reverses the input list, outputing a new, reversed list. The output is a strict cons list." } ; { $description "Reverses the input list, outputing a new, reversed list. The output is a strict cons list." } ;
HELP: list>array HELP: list>array
{ $values { "list" "a cons object" } { "array" array } }
{ $description "Turns the given cons object into an array, maintaing order." } ;
HELP: sequence>cons
{ $values { "sequence" sequence } { "list" cons } }
{ $description "Turns the given array into a cons object, maintaing order." } ;
HELP: deep-list>array
{ $values { "list" list } { "array" array } } { $values { "list" list } { "array" array } }
{ $description "Recursively turns the given cons object into an array, maintaing order and also converting nested lists." } ; { $description "Convert a list into an array." } ;
HELP: deep-sequence>cons
{ $values { "sequence" sequence } { "cons" cons } }
{ $description "Recursively turns the given sequence into a cons object, maintaing order and also converting nested lists." } ;
HELP: traverse HELP: traverse
{ $values { "list" "a cons object" } { "pred" { $quotation "( list/elt -- ? )" } } { $values { "list" list } { "pred" { $quotation "( list/elt -- ? )" } }
{ "quot" { $quotation "( list/elt -- result)" } } { "result" "a new cons object" } } { "quot" { $quotation "( list/elt -- result)" } } { "result" "a new cons object" } }
{ $description "Recursively traverses the list object, replacing any elements (which can themselves be sublists) that pred" { $description "Recursively traverses the list object, replacing any elements (which can themselves be sublists) that pred"
" returns true for with the result of applying quot to." } ; " returns true for with the result of applying quot to." } ;
@ -178,6 +164,3 @@ HELP: lmap>array
{ $values { "list" list } { "quot" quotation } { "array" array } } { $values { "list" list } { "quot" quotation } { "array" array } }
{ $description "Executes the quotation on each element of the list, collecting the results in an array." } ; { $description "Executes the quotation on each element of the list, collecting the results in an array." } ;
HELP: lmap-as
{ $values { "list" list } { "quot" quotation } { "exemplar" sequence } { "sequence" sequence } }
{ $description "Executes the quotation on each element of the list, collecting the results in a sequence of the type given by the exemplar." } ;

Some files were not shown because too many files have changed in this diff Show More