handbook updates, HTML-format changelog

cvs
Slava Pestov 2005-07-22 01:43:37 +00:00
parent 3956f12627
commit 50eeb1db28
24 changed files with 183 additions and 265 deletions

113
CHANGES.html Normal file
View File

@ -0,0 +1,113 @@
<html>
<head><title>Factor change log</title></head>
<body>
<h1>Factor 0.76:</h1>
<!-- :noWordSep=+-*\=><;.?/'()%,_|: -->
<ul>
<li>
Major improvements to the GUI:
<ul>
<li>Now uses 3-dimensional co-ordinates throughout</li>
<li>The listener supports styled text output and presentations</li>
<li>Gradient paint, bevel border paint</li>
<li>Wheel mouse scrolling</li>
<li>Slide-show tutorial with live code examples</li>
<li>Performance improvements, code cleanups, bug fixes</li>
</ul>
</li>
<li>
Sequences:
<ul>
<li>The following formely list-specific words are now generic:
<pre>all? ( seq quot -- ? | quot: elt -- ? )
all-with? ( obj seq quot -- ? | quot: elt -- ? )
subset ( seq quot -- seq | quot: elt -- ? )
subset-with ( obj seq quot -- seq | quot: obj elt -- ? )
fiber? ( seq quot -- ? | quot: elt elt -- ? )
prune ( seq -- seq )</pre>
<li> The <code>contains?</code> word for testing membership in a sequence has been
renamed to <code>member? ( elt seq -- ? )</code>.
<li> The list-specific <code>some?</code> and <code>some-with?</code> combinators are gone. Their replacements are generic:
<pre>contains? ( seq quot -- ? | quot: elt -- ? )
contains-with? ( obj seq quot -- ? | quot: obj elt -- ? )
find ( seq quot -- i elt | quot: elt -- ? )
find* ( i seq quot -- i elt | quot: elt -- ? )
find-with ( obj seq quot -- i elt | quot: elt -- ? )
find-with* ( obj i seq quot -- i elt | quot: elt -- ? )</pre>
See the developer's handbook for details.
<li> The <code>nreverse ( seq -- )</code> word has been removed.
<li> <code>reverse-slice ( seq -- seq )</code> outputs a new sequence that shares
structure with the given sequence, but presents elements in reverse
order.
<li> The <code>string-compare</code> primitive has been replaced with the lexi word
which now operates on any pair of sequences of numbers. The
string> word has been replaced with <code>>lexi></code>.
<li> The <code>,</code> word no longer accepts a string as input inside a <code>make-string</code>. In 0.75, the following
two lines were equivalent:
<pre>[ "Hello" , " world" , ] make-string
[ "Hello" % " world" % ] make-string</pre>
<li> Now, the former raises a type error. Use <code>,</code> with characters, and <code>%</code> with
strings inside make-string.
</ul>
<li>Streams:
<ul>
<li>The following words have been renamed:
<pre>stream-auto-flush ==> stream-finish ( stream -- )
stream-write-attr ==> stream-format ( string style stream -- )
write-attr ==> format ( string style -- )</pre>
<li>The following words no longer accept character arguments:
<pre>stream-format ( string style stream -- )
format ( string style -- )
stream-write ( string stream -- )
write ( string -- )
stream-print ( string -- )
print ( string -- )</pre>
<li>Use the new words to write characters:
<pre>stream-write1 ( char stream -- )
write1 ( char -- )</pre>
Note that <code>stream-write1</code> is generic and your stream must implement it.
<li><code>with-string</code> word renamed to <code>string-out ( quot -- string )</code>
<li>New <code>string-in ( string quot -- )</code> word, calls <code>quot</code> with <code>stdio</code> bound to
a stream that reads from the given string.
</ul>
<li>Many improvements to the matrices library.
<li>Improved inspector. Call it with <code>inspect ( obj -- )</code>.
<li>The number of generations used for garbage collection can now be set
with the +G command line switch. You must specify at least 2
generations.
<li>Only 2 generations are used by default now, since there seems to be no
performance benefit to having 3 after running some brief benchmarks.
<li>Fixed bug where images saved from the jEdit plugin would fail to
start.
<li>md5 hashing algorithm in <code>contrib/crypto/</code> (Doug Coleman).
</ul>

View File

@ -1,191 +0,0 @@
Factor 0.76:
------------
- Major improvements to the GUI:
- The listener supports styled text output and presentations
- Gradient paint, bevel border paint
- Wheel mouse scrolling
- Slide-show tutorial with live code examples
- Performance improvements, code cleanups, bug fixes
- The following formely list-specific words are now generic:
all? all-with? subset subset-with fiber? prune
- The contains? word for testing membership in a sequence has been
renamed to member?.
- The some? and some-with? combinators are gone. Their replacements
are contains?, contains-with?, find, find*, find-with, and find-with*.
See the documentation for details.
- The nreverse word has been removed.
- The , word no longer accepts a string as input. Formely, the following
two lines were equivalent:
[ "Hello" , " world" , ] make-string
[ "Hello" % " world" % ] make-string
Now, the former raises a type error.
- The string-compare primitive has been replaced with the lexi word
which now operates on any pair of sequences of numbers. The
string> word has been replaced with lexi>.
- The stream-write, stream-write-attr, write and write-attr generic
words no longer accept a character as an argument. Use the new
stream-write1 and write1 generic words to write single characters.
- reverse-slice ( seq -- seq ) outputs a new sequence that shares
structure with the given sequence, but presents elements in reverse
order.
- Many improvements to the matrices library.
- with-string word renamed to string-out ( quot -- string )
- new string-in ( string quot -- ) word, calls quot with stdio bound to
a stream that reads from the given string.
- Improved inspector. Call it with inspect ( obj -- ).
- The number of generations used for garbage collection can now be set
with the +G command line switch. You must specify at least 2
generations.
- Only 2 generations are used by default now, since there seems to be no
performance benefit to having 3 after running some brief benchmarks.
- Fixed bug where images saved from the jEdit plugin would fail to
start.
- md5 hashing algorithm in contrib/crypto/ (Doug Coleman).
Factor 0.75:
------------
+ Runtime and core library
- Fix for a fatal bug where Factor was not functional on Mac OS X 10.4.
- Client sockets were not functional on Linux.
- New generational garbage collector. There are two command line
switches for controlling it:
+Yn Size of 2 youngest generations, megabytes
+An Size of tenured and semi-spaces, megabytes
- Generic words can now dispatch on stack elements other than the top
one; define your generic like this to dispatch on the second element:
G: foo [ over ] [ type ] ;
Or this for the third:
G: foo [ pick ] [ type ] ;
Note that GENERIC: foo is the same as
G: foo [ dup ] [ type ] ;
- Sequence API refactoring, as described in
http://www.jroller.com/page/slava/20050518.
- The SO_OOBINLINE socket flag is now set. In 0.74, sending out-of-band
data could fill up the buffer and cause a denial-of-service attack.
- You can now set timeouts for I/O operations with the set-timeout
generic word. The HTTP server sets a timeout of 60 seconds for client
requests.
- Improved the words for doing binary I/O; see library/io/binary.factor
and the section in the handbook on binary I/O.
+ Compiler
- The compiler now does constant folding for certain words with literal
operands. The compiler's peephole optimizer has been improved.
- The alien interface now supports "float" and "double" types, and
arrays of C types.
- New short-hand syntax for defining words that alien-invoke
(Alex Chapman).
LIBRARY: gl
FUNCTION: void glTranslatef ( GLfloat x, GLfloat y, GLfloat z ) ;
should be the same as doing:
: glTranslatef ( x y z -- )
"void" "gl" "glTranslatef"
[ "GLfloat" "GLfloat" "GLfloat" ] alien-invoke ;
\ glTranslatef compile
+ Framework
- OpenGL binding in contrib/gl/ (Alex Chapman).
- PostgreSQL binding in contrib/postgresql/ (Doug Coleman).
- HTTP server now supports virtual hosting.
- The Factor plugin now supports connecting to Factor instances on
arbitrary host and port names. This allows interactive development on
one machine while testing on another. A new command was added to
evaluate the word definition at the caret in the listener.
Factor 0.74:
------------
C library interface ported to Linux/PPC and Mac OS X.
Developer's handbook rewritten to be more up to date and complete.
Added the sequences vocabulary that unifies code for working with lists,
vectors, strings, and string buffers. There are many changes, and most
of the old type-specific words such as vector-nth and string-map are
gone.
Added the matrices vocabulary for working with mathematical vectors and
matrices.
Added two words for modular arithmetic in the math vocabulary: mod-inv
and ^mod.
Added HTTP client API supporting GET and POST requests in the
http-client vocabulary.
Removed some inspection words: vocabs. words. usages. Now, just put a
space before the . and write vocabs . words . usages .
Redefining words that are used by compiled words automatically
decompiles the compiled words. This fixes the problem of new definitions
not taking effect. In a future release, there will be automatic
recompilation, rather than decompilation.
As a result of the previous change, there is now a cross-referencing
database, and the usages word lists indirect dependencies and is much
faster. The usage word behaves like the old usages, and lists direct
dependencies only.
The dump word in the dump vocabulary prints the memory bytes comprising
an object. The dump* word prints the bytes at an arbitrary address.
New words in words vocabulary for inspecting classes and methods:
classes implements.
The Unix I/O code was rewritten in Factor using the C library interface.
Many new features will be added in future releases, such as socket
timeouts and Unicode character encodings.
Lazy lists and parser combinators library in contrib/parser-combinators/
(Chris Double).
Quotations containing \ foo are prettyprinted in that form.
The watch word now causes annotated words to dump the stack, in addition
to printing a log message.

View File

@ -3872,7 +3872,7 @@ String buffers support the stream output protocol. See \ref{stdio}.
\glossary{name=input stream,
description={a stream that implements the \texttt{stream-readln} and \texttt{stream-read} generic words and can be used for character input}}
\glossary{name=output stream,
description={a stream that implements the \texttt{stream-write-attr}, \texttt{stream-flush} and \texttt{stream-auto-flush} generic words and can be used for character output}}
description={a stream that implements the \texttt{stream-write-attr}, \texttt{stream-flush} and \texttt{stream-finish} generic words and can be used for character output}}
There are various subsets of the stream protocol that a class can implement so that its instances may be used as streams. The following generic word is mandatory.
@ -3926,11 +3926,11 @@ Ensures all pending output operations are been complete. With many output stream
\wordtable{
\vocabulary{io}
\genericword{stream-auto-flush}{stream-auto-flush ( s -- )}
\genericword{stream-finish}{stream-finish ( s -- )}
}
Ensures the user sees prior output. It is not as strong as \texttt{stream-flush}. The contract is as follows: if the stream is connected to an interactive end-point such as a terminal, \texttt{stream-auto-flush} should execute \texttt{stream-flush}. If the stream is a file or network stream used for ``batch'' operations, this word should have an empty definition.
Ensures the user sees prior output. It is not as strong as \texttt{stream-flush}. The contract is as follows: if the stream is connected to an interactive end-point such as a terminal, \texttt{stream-finish} should execute \texttt{stream-flush}. If the stream is a file or network stream used for ``batch'' operations, this word should have an empty definition.
The \texttt{stream-print} word executes \texttt{stream-auto-flush} after each line of output.
The \texttt{stream-print} word executes \texttt{stream-finish} after each line of output.
With some streams, the above operations may suspend the current thread and execute other threads until input data is available (\ref{threads}).
@ -3951,7 +3951,7 @@ Outputs a string to the stream, without any specific style information. Implemen
\vocabulary{io}
\ordinaryword{stream-print}{stream-print ( string stream -- )}
}
Outputs a string to the stream, followed by a newline, then executes \texttt{stream-auto-flush} to force the line to be displayed on interactive streams.
Outputs a string to the stream, followed by a newline, then executes \texttt{stream-finish} to force the line to be displayed on interactive streams.
\section{The default stream}\label{stdio}
\glossary{name=default stream,

View File

@ -83,7 +83,7 @@ M: object find ( seq quot -- i elt )
#! ForAll(P in X) <==> !Exists(!P in X)
swap [ swap call not ] contains-with? not ; inline
: all-with? ( obj list pred -- ? )
: all-with? ( obj seq quot -- ? | quot: elt -- ? )
swap [ with rot ] all? 2nip ; inline
: subset ( seq quot -- seq | quot: elt -- ? )
@ -99,7 +99,7 @@ M: object find ( seq quot -- i elt )
] each drop
] keep like ; inline
: subset-with ( obj list quot -- list )
: subset-with ( obj seq quot -- seq | quot: obj elt -- ? )
swap [ with rot ] subset 2nip ; inline
: fiber? ( seq quot -- ? | quot: elt elt -- ? )

View File

@ -7,7 +7,7 @@ USING: errors generic kernel math math-internals strings vectors ;
! Sequences support the following protocol. Concrete examples
! are strings, string buffers, vectors, and arrays. Arrays are
! low level and not bounds-checked; they are in the
! low level and no | quot: elt -- ? t bounds-checked; they are in the
! kernel-internals vocabulary, so don't use them unless you have
! a good reason.
@ -41,16 +41,16 @@ G: each ( seq quot -- | quot: elt -- )
G: 2map ( seq seq quot -- seq | quot: elt elt -- elt )
[ over ] [ type ] ; inline
G: find ( seq quot -- i elt )
G: find ( seq quot -- i elt | quot: elt -- ? )
[ over ] [ type ] ; inline
: find-with ( obj seq quot -- i elt )
: find-with ( obj seq quot -- i elt | quot: elt -- ? )
swap [ with rot ] find 2swap 2drop ; inline
G: find* ( i seq quot -- i elt )
G: find* ( i seq quot -- i elt | quot: elt -- ? )
[ over ] [ type ] ; inline
: find-with* ( obj i seq quot -- i elt )
: find-with* ( obj i seq quot -- i elt | quot: elt -- ? )
-rot [ with rot ] find* 2swap 2drop ; inline
: first 0 swap nth ; inline

View File

@ -106,7 +106,7 @@ M: html-stream stream-write1 ( char stream -- )
dup html-entities assoc [ write ] [ write1 ] ?ifte
] with-wrapper ;
M: html-stream stream-write-attr ( str style stream -- )
M: html-stream stream-format ( str style stream -- )
[
[
[

View File

@ -21,7 +21,7 @@ io strings unparser ;
: read-response ( -- code header )
#! After sending a GET oR POST we read a response line and
#! header.
flush read-line parse-response read-header ;
flush readln parse-response read-header ;
: http-request ( host resource method -- )
write CHAR: \s write write " HTTP/1.0" write crlf

View File

@ -7,7 +7,7 @@ io strings unparser ;
": " split1 dup [ cons swons ] [ 2drop ] ifte ;
: (read-header) ( alist -- alist )
read-line dup
readln dup
empty? [ drop ] [ header-line (read-header) ] ifte ;
: read-header ( -- alist )

View File

@ -52,7 +52,7 @@ sequences ;
: httpd-client ( socket -- )
dup log-client [
60000 stdio get set-timeout
read-line [ parse-request ] when*
readln [ parse-request ] when*
] with-stream ;
: httpd-connection ( socket -- )

View File

@ -15,7 +15,7 @@ TUPLE: c-stream in out flush? ;
M: c-stream stream-write1 ( char stream -- )
>r ch>string r> c-stream-out fwrite ;
M: c-stream stream-write-attr ( str style stream -- )
M: c-stream stream-format ( str style stream -- )
nip c-stream-out fwrite ;
M: c-stream stream-read1 ( stream -- char/f )

View File

@ -11,7 +11,7 @@ sequences strings unparser ;
: file-icon. directory? dir-icon file-icon ? write-icon ;
: file-link. ( dir name -- )
tuck path+ "file" swons unit write-attr ;
tuck path+ "file" swons unit format ;
: file. ( dir name -- )
#! If "doc-root" set, create links relative to it.

View File

@ -23,8 +23,8 @@ M: duplex-stream stream-read
M: duplex-stream stream-write1
duplex-stream-out stream-write1 ;
M: duplex-stream stream-write-attr
duplex-stream-out stream-write-attr ;
M: duplex-stream stream-format
duplex-stream-out stream-format ;
M: duplex-stream stream-close
#! The output stream is closed first, in case both streams

View File

@ -9,16 +9,16 @@ C: line-reader ( stream -- line ) [ set-delegate ] keep ;
: cr> dup line-reader-cr f rot set-line-reader-cr ;
: (read-line) ( ? line -- ? )
: (readln) ( ? line -- ? )
#! The flag is set after the first character is read.
dup delegate stream-read1 dup [
>r >r drop t r> r> dup CHAR: \r = [
drop t swap set-line-reader-cr
] [
dup CHAR: \n = [
drop dup cr> [ (read-line) ] [ drop ] ifte
drop dup cr> [ (readln) ] [ drop ] ifte
] [
, (read-line)
, (readln)
] ifte
] ifte
] [
@ -26,7 +26,7 @@ C: line-reader ( stream -- line ) [ set-delegate ] keep ;
] ifte ;
M: line-reader stream-readln ( line -- string )
[ f swap (read-line) ] make-string
[ f swap (readln) ] make-string
dup empty? [ f ? ] [ nip ] ifte ;
M: line-reader stream-read ( count line -- string )

View File

@ -3,26 +3,27 @@
IN: io
USING: errors generic kernel lists namespaces strings styles ;
: flush ( -- ) stdio get stream-flush ;
: read-line ( -- string ) stdio get stream-readln ;
: read1 ( -- char/f ) stdio get stream-read1 ;
: read ( count -- string ) stdio get stream-read ;
: write ( string -- ) stdio get stream-write ;
: write1 ( char -- ) stdio get stream-write1 ;
: write-attr ( string style -- ) stdio get stream-write-attr ;
: print ( string -- ) stdio get stream-print ;
: terpri ( -- ) stdio get stream-terpri ;
: crlf ( -- ) "\r\n" write ;
: bl ( -- ) " " write ;
: close ( -- ) stdio get stream-close ;
: flush ( -- ) stdio get stream-flush ;
: readln ( -- string/f ) stdio get stream-readln ;
: read1 ( -- char/f ) stdio get stream-read1 ;
: read ( count -- string ) stdio get stream-read ;
: write ( string -- ) stdio get stream-write ;
: write1 ( char -- ) stdio get stream-write1 ;
: format ( string style -- ) stdio get stream-format ;
: print ( string -- ) stdio get stream-print ;
: terpri ( -- ) stdio get stream-terpri ;
: close ( -- ) stdio get stream-close ;
: crlf ( -- ) "\r\n" write ;
: bl ( -- ) " " write ;
: write-icon ( resource -- )
#! Write an icon. Eg, /library/icons/File.png
icon swons unit "" swap write-attr ;
icon swons unit "" swap format ;
: with-stream ( stream quot -- )
#! Close the stream no matter what happends.
[ swap stdio set [ close rethrow ] catch ] with-scope ;
#! Close the stream no matter what happens.
[ swap stdio set [ close rethrow ] catch ] with-scope ;
: with-stream* ( stream quot -- )
#! Close the stream if there is an error.

View File

@ -7,33 +7,28 @@ strings ;
SYMBOL: stdio
! Stream protocol.
GENERIC: stream-flush ( stream -- )
GENERIC: stream-finish ( stream -- )
GENERIC: stream-readln ( stream -- string )
GENERIC: stream-read1 ( stream -- char/f )
GENERIC: stream-read ( count stream -- string )
GENERIC: stream-write1 ( char stream -- )
GENERIC: stream-write-attr ( string style stream -- )
GENERIC: stream-close ( stream -- )
GENERIC: set-timeout ( timeout stream -- )
GENERIC: stream-flush ( stream -- )
GENERIC: stream-finish ( stream -- )
GENERIC: stream-readln ( stream -- string )
GENERIC: stream-read1 ( stream -- char/f )
GENERIC: stream-read ( count stream -- string )
GENERIC: stream-write1 ( char stream -- )
GENERIC: stream-format ( string style stream -- )
GENERIC: stream-close ( stream -- )
GENERIC: set-timeout ( timeout stream -- )
: stream-write ( string stream -- )
f swap stream-format ;
: stream-terpri ( stream -- )
"\n" swap stream-write ;
: stream-write ( string stream -- )
f swap stream-write-attr ;
: stream-print ( string stream -- )
[ stream-write ] keep
[ stream-write ] keep
stream-finish ;
[ stream-write ] keep dup stream-terpri stream-finish ;
: (stream-copy) ( in out -- )
4096 pick stream-read [
over stream-write (stream-copy)
] [
2drop
] ifte* ;
4096 pick stream-read
[ over stream-write (stream-copy) ] [ 2drop ] ifte* ;
: stream-copy ( in out -- )
[ 2dup (stream-copy) ]
@ -47,7 +42,7 @@ M: null-stream stream-readln drop f ;
M: null-stream stream-read 2drop f ;
M: null-stream stream-read1 drop f ;
M: null-stream stream-write1 2drop ;
M: null-stream stream-write-attr 3drop ;
M: null-stream stream-format 3drop ;
M: null-stream stream-close drop ;
! Sometimes, we want to have a delegating stream that uses stdio

View File

@ -2,7 +2,7 @@ USING: io kernel math namespaces sequences strings ;
! String buffers support the stream output protocol.
M: sbuf stream-write1 push ;
M: sbuf stream-write-attr rot nappend drop ;
M: sbuf stream-format rot nappend drop ;
M: sbuf stream-close drop ;
M: sbuf stream-flush drop ;
M: sbuf stream-finish drop ;

View File

@ -13,7 +13,7 @@ SYMBOL: recursion-check
GENERIC: prettyprint* ( indent obj -- indent )
: unparse. ( obj -- )
dup unparse swap presented swons unit write-attr ;
dup unparse swap presented swons unit format ;
M: object prettyprint* ( indent obj -- indent )
unparse. ;

View File

@ -20,7 +20,7 @@ streams strings styles unparser words ;
\ inline prettyprint-prop ;
: comment. ( comment -- )
[ [[ font-style italic ]] ] write-attr ;
[ [[ font-style italic ]] ] format ;
: infer-effect. ( effect -- )
[

View File

@ -38,12 +38,12 @@ USING: html io kernel namespaces styles test ;
] string-out
] unit-test
: html-write-attr ( string style -- string )
[ write-attr ] with-html-stream ;
: html-format ( string style -- string )
[ format ] with-html-stream ;
[ "hello world" ]
[
[ "hello world" [ ] html-write-attr ] string-out
[ "hello world" [ ] html-format ] string-out
] unit-test
[ "<span style='color: #ff00ff; font-family: Monospaced; '>car</span>" ]
@ -51,7 +51,7 @@ USING: html io kernel namespaces styles test ;
[
"car"
[ [ foreground 255 0 255 ] [[ font "Monospaced" ]] ]
html-write-attr
html-format
] string-out
] unit-test

View File

@ -4,7 +4,7 @@ USING: io kernel math parser strings test ;
[ 4 ] [ "/library/test/io/no-trailing-eol.factor" run-resource ] unit-test
: lines-test ( stream -- line1 line2 )
[ read-line read-line ] with-stream ;
[ readln readln ] with-stream ;
[
"This is a line."

View File

@ -13,9 +13,9 @@ unparser words ;
: jedit-server-info ( -- port auth )
jedit-server-file <file-reader> [
read-line drop
read-line parse-number
read-line parse-number
readln drop
readln parse-number
readln parse-number
] with-stream ;
: make-jedit-request ( files params -- code )

View File

@ -16,7 +16,7 @@ global [ " " listener-prompt set ] bind
: (read-multiline) ( quot depth -- quot ? )
#! Flag indicates EOF.
>r read-line dup [
>r readln dup [
(parse) depth r> dup >r <= [
( we're done ) r> drop t
] [

View File

@ -101,7 +101,7 @@ M: pane stream-readln ( stream -- line )
M: pane stream-write1 ( string style stream -- )
[ rot ch>string unit pane-write ] keep scroll>bottom ;
M: pane stream-write-attr ( string style stream -- )
M: pane stream-format ( string style stream -- )
[ rot "\n" split pane-write ] keep scroll>bottom ;
M: pane stream-close ( stream -- ) drop ;

View File

@ -288,7 +288,7 @@ M: port stream-finish ( stream -- ) drop ;
M: port stream-write1 ( char writer -- )
1 over wait-to-write ch>buffer ;
M: port stream-write-attr ( string style writer -- )
M: port stream-format ( string style writer -- )
nip over length over wait-to-write >buffer ;
M: port stream-close ( stream -- )