From 688cbfaafacf383374b162d6163ca957f7b84032 Mon Sep 17 00:00:00 2001 From: Chris Double Date: Fri, 11 Apr 2008 14:46:11 +1200 Subject: [PATCH 01/26] Delocalise grow-lr --- extra/peg/peg.factor | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/extra/peg/peg.factor b/extra/peg/peg.factor index 7390c15684..164f7c9ee9 100755 --- a/extra/peg/peg.factor +++ b/extra/peg/peg.factor @@ -100,21 +100,21 @@ C: peg-head : setup-growth ( h p -- ) pos set dup involved-set>> clone >>eval-set drop ; -:: (grow-lr) ( h p r m -- ) - h p setup-growth - r eval-rule - dup m stop-growth? [ - drop +: (grow-lr) ( h p r m -- ) + >r >r [ setup-growth ] 2keep r> r> + >r dup eval-rule r> swap + dup pick stop-growth? [ + 4drop drop ] [ - m update-m - h p r m (grow-lr) + over update-m + (grow-lr) ] if ; inline -:: grow-lr ( h p r m -- ast ) - h p heads get set-at - h p r m (grow-lr) - p heads get delete-at - m pos>> pos set m ans>> +: grow-lr ( h p r m -- ast ) + >r >r [ heads get set-at ] 2keep r> r> + pick over >r >r (grow-lr) r> r> + swap heads get delete-at + dup pos>> pos set ans>> ; inline :: (setup-lr) ( r l s -- ) From fafd00bae7f2d1354366395f7f014004d5f55c97 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 13 Apr 2008 12:54:58 -0500 Subject: [PATCH 02/26] rename new -> new-sequence --- core/arrays/arrays.factor | 4 ++-- core/bit-arrays/bit-arrays.factor | 2 +- core/bit-vectors/bit-vectors.factor | 2 +- core/bootstrap/compiler/compiler.factor | 2 +- core/byte-arrays/byte-arrays.factor | 2 +- core/byte-vectors/byte-vectors.factor | 2 +- core/float-arrays/float-arrays.factor | 2 +- core/float-vectors/float-vectors.factor | 2 +- core/sbufs/sbufs.factor | 2 +- core/sequences/sequences-docs.factor | 4 ++-- core/sequences/sequences.factor | 10 +++++----- core/strings/strings.factor | 2 +- core/vectors/vectors.factor | 2 +- extra/sequences/next/next.factor | 2 +- 14 files changed, 20 insertions(+), 20 deletions(-) diff --git a/core/arrays/arrays.factor b/core/arrays/arrays.factor index 414c64581e..9c5f40d883 100755 --- a/core/arrays/arrays.factor +++ b/core/arrays/arrays.factor @@ -12,9 +12,9 @@ M: array resize resize-array ; : >array ( seq -- array ) { } clone-like ; -M: object new drop f ; +M: object new-sequence drop f ; -M: f new drop dup zero? [ drop f ] [ f ] if ; +M: f new-sequence drop dup zero? [ drop f ] [ f ] if ; M: array like drop dup array? [ >array ] unless ; diff --git a/core/bit-arrays/bit-arrays.factor b/core/bit-arrays/bit-arrays.factor index ee485d399e..ffb9f5d195 100755 --- a/core/bit-arrays/bit-arrays.factor +++ b/core/bit-arrays/bit-arrays.factor @@ -43,7 +43,7 @@ M: bit-array clone (clone) ; M: bit-array like drop dup bit-array? [ >bit-array ] unless ; -M: bit-array new drop ; +M: bit-array new-sequence drop ; M: bit-array equal? over bit-array? [ sequence= ] [ 2drop f ] if ; diff --git a/core/bit-vectors/bit-vectors.factor b/core/bit-vectors/bit-vectors.factor index c418a24813..3949dc2632 100755 --- a/core/bit-vectors/bit-vectors.factor +++ b/core/bit-vectors/bit-vectors.factor @@ -22,7 +22,7 @@ M: bit-vector like [ dup length bit-array>vector ] [ >bit-vector ] if ] unless ; -M: bit-vector new +M: bit-vector new-sequence drop [ ] keep >fixnum bit-array>vector ; M: bit-vector equal? diff --git a/core/bootstrap/compiler/compiler.factor b/core/bootstrap/compiler/compiler.factor index 9e101126e6..da3c634ebd 100755 --- a/core/bootstrap/compiler/compiler.factor +++ b/core/bootstrap/compiler/compiler.factor @@ -53,7 +53,7 @@ nl "." write flush { - new nth push pop peek + new-sequence nth push pop peek } compile "." write flush diff --git a/core/byte-arrays/byte-arrays.factor b/core/byte-arrays/byte-arrays.factor index 548c293e7c..d603470810 100755 --- a/core/byte-arrays/byte-arrays.factor +++ b/core/byte-arrays/byte-arrays.factor @@ -10,7 +10,7 @@ M: byte-array nth-unsafe swap >fixnum alien-unsigned-1 ; M: byte-array set-nth-unsafe swap >fixnum set-alien-unsigned-1 ; : >byte-array ( seq -- byte-array ) B{ } clone-like ; inline M: byte-array like drop dup byte-array? [ >byte-array ] unless ; -M: byte-array new drop ; +M: byte-array new-sequence drop ; M: byte-array equal? over byte-array? [ sequence= ] [ 2drop f ] if ; diff --git a/core/byte-vectors/byte-vectors.factor b/core/byte-vectors/byte-vectors.factor index 6a08f657a2..9a0185319f 100755 --- a/core/byte-vectors/byte-vectors.factor +++ b/core/byte-vectors/byte-vectors.factor @@ -22,7 +22,7 @@ M: byte-vector like [ dup length byte-array>vector ] [ >byte-vector ] if ] unless ; -M: byte-vector new +M: byte-vector new-sequence drop [ ] keep >fixnum byte-array>vector ; M: byte-vector equal? diff --git a/core/float-arrays/float-arrays.factor b/core/float-arrays/float-arrays.factor index 33302572de..d25d447a46 100755 --- a/core/float-arrays/float-arrays.factor +++ b/core/float-arrays/float-arrays.factor @@ -24,7 +24,7 @@ M: float-array set-nth-unsafe M: float-array like drop dup float-array? [ >float-array ] unless ; -M: float-array new drop 0.0 ; +M: float-array new-sequence drop 0.0 ; M: float-array equal? over float-array? [ sequence= ] [ 2drop f ] if ; diff --git a/core/float-vectors/float-vectors.factor b/core/float-vectors/float-vectors.factor index 2b023985a4..11535e349e 100755 --- a/core/float-vectors/float-vectors.factor +++ b/core/float-vectors/float-vectors.factor @@ -22,7 +22,7 @@ M: float-vector like [ dup length float-array>vector ] [ >float-vector ] if ] unless ; -M: float-vector new +M: float-vector new-sequence drop [ 0.0 ] keep >fixnum float-array>vector ; M: float-vector equal? diff --git a/core/sbufs/sbufs.factor b/core/sbufs/sbufs.factor index 9de57c0801..69cbad2cd3 100755 --- a/core/sbufs/sbufs.factor +++ b/core/sbufs/sbufs.factor @@ -16,7 +16,7 @@ PRIVATE> M: sbuf set-nth-unsafe underlying >r >r >fixnum r> >fixnum r> set-string-nth ; -M: sbuf new drop [ 0 ] keep >fixnum string>sbuf ; +M: sbuf new-sequence drop [ 0 ] keep >fixnum string>sbuf ; : >sbuf ( seq -- sbuf ) SBUF" " clone-like ; inline diff --git a/core/sequences/sequences-docs.factor b/core/sequences/sequences-docs.factor index 473aa03d7a..b7ad22996f 100755 --- a/core/sequences/sequences-docs.factor +++ b/core/sequences/sequences-docs.factor @@ -33,7 +33,7 @@ ARTICLE: "sequence-protocol" "Sequence protocol" "An optional generic word for creating sequences of the same class as a given sequence:" { $subsection like } "Optional generic words for optimization purposes:" -{ $subsection new } +{ $subsection new-sequence } { $subsection new-resizable } { $see-also "sequences-unsafe" } ; @@ -281,7 +281,7 @@ HELP: immutable { $description "Throws an " { $link immutable } " error." } { $error-description "Thrown if an attempt is made to modify an immutable sequence." } ; -HELP: new +HELP: new-sequence { $values { "len" "a non-negative integer" } { "seq" sequence } { "newseq" "a mutable sequence" } } { $contract "Outputs a mutable sequence of length " { $snippet "n" } " which can hold the elements of " { $snippet "seq" } "." } ; diff --git a/core/sequences/sequences.factor b/core/sequences/sequences.factor index 996aba8e6e..7061ac3933 100755 --- a/core/sequences/sequences.factor +++ b/core/sequences/sequences.factor @@ -9,13 +9,13 @@ GENERIC: length ( seq -- n ) flushable GENERIC: set-length ( n seq -- ) GENERIC: nth ( n seq -- elt ) flushable GENERIC: set-nth ( elt n seq -- ) -GENERIC: new ( len seq -- newseq ) flushable +GENERIC: new-sequence ( len seq -- newseq ) flushable GENERIC: new-resizable ( len seq -- newseq ) flushable GENERIC: like ( seq exemplar -- newseq ) flushable GENERIC: clone-like ( seq exemplar -- newseq ) flushable : new-like ( len exemplar quot -- seq ) - over >r >r new r> call r> like ; inline + over >r >r new-sequence r> call r> like ; inline M: sequence like drop ; @@ -162,7 +162,7 @@ M: virtual-sequence set-nth virtual@ set-nth ; M: virtual-sequence nth-unsafe virtual@ nth-unsafe ; M: virtual-sequence set-nth-unsafe virtual@ set-nth-unsafe ; M: virtual-sequence like virtual-seq like ; -M: virtual-sequence new virtual-seq new ; +M: virtual-sequence new-sequence virtual-seq new-sequence ; INSTANCE: virtual-sequence sequence @@ -250,7 +250,7 @@ INSTANCE: repetition immutable-sequence dup 0 <= [ 2drop 2drop ] [ 1- ((copy)) (copy) ] if ; inline : prepare-subseq ( from to seq -- dst i src j n ) - [ >r swap - r> new dup 0 ] 3keep + [ >r swap - r> new-sequence dup 0 ] 3keep -rot drop roll length ; inline : check-copy ( src n dst -- ) @@ -275,7 +275,7 @@ PRIVATE> (copy) drop ; inline M: sequence clone-like - >r dup length r> new [ 0 swap copy ] keep ; + >r dup length r> new-sequence [ 0 swap copy ] keep ; M: immutable-sequence clone-like like ; diff --git a/core/strings/strings.factor b/core/strings/strings.factor index bb3c94ce97..1484737277 100755 --- a/core/strings/strings.factor +++ b/core/strings/strings.factor @@ -46,6 +46,6 @@ M: string resize resize-string ; : >string ( seq -- str ) "" clone-like ; -M: string new drop 0 ; +M: string new-sequence drop 0 ; INSTANCE: string sequence diff --git a/core/vectors/vectors.factor b/core/vectors/vectors.factor index 1820c62ff4..aa827fd726 100755 --- a/core/vectors/vectors.factor +++ b/core/vectors/vectors.factor @@ -19,7 +19,7 @@ M: vector like dup array? [ dup length array>vector ] [ >vector ] if ] unless ; -M: vector new drop [ f ] keep >fixnum array>vector ; +M: vector new-sequence drop [ f ] keep >fixnum array>vector ; M: vector equal? over vector? [ sequence= ] [ 2drop f ] if ; diff --git a/extra/sequences/next/next.factor b/extra/sequences/next/next.factor index 5919fb0701..b22bf2683c 100755 --- a/extra/sequences/next/next.factor +++ b/extra/sequences/next/next.factor @@ -17,6 +17,6 @@ PRIVATE> : map-next ( seq quot -- newseq ) ! quot: next-elt elt -- newelt - over dup length swap new >r + over dup length swap new-sequence >r iterate-seq [ (map-next) ] 2curry r> [ collect ] keep ; inline From 9a734b74cee2e2e99f65930b37ca18ad9efb2a7e Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 13 Apr 2008 14:48:42 -0500 Subject: [PATCH 03/26] Update readme --- README.txt | 109 ++++++++++++++++++----------------------------------- 1 file changed, 36 insertions(+), 73 deletions(-) diff --git a/README.txt b/README.txt index 12dade5ba1..dd7c3e7ad3 100755 --- a/README.txt +++ b/README.txt @@ -6,7 +6,6 @@ implementation. It is not an introduction to the language itself. * Contents -- Platform support - Compiling the Factor VM - Libraries needed for compilation - Bootstrapping the Factor image @@ -19,80 +18,50 @@ implementation. It is not an introduction to the language itself. - Source organization - Community -* Platform support - -Factor supports the following platforms: - - Linux/x86 - Linux/AMD64 - Linux/PowerPC - Linux/ARM - Mac OS X/x86 - Mac OS X/PowerPC - FreeBSD/x86 - FreeBSD/AMD64 - OpenBSD/x86 - OpenBSD/AMD64 - Solaris/x86 - Solaris/AMD64 - MS Windows/x86 (XP and above) - MS Windows CE/ARM - -Please donate time or hardware if you wish to see Factor running on -other platforms. In particular, we are interested in: - - Windows/AMD64 - Mac OS X/AMD64 - Solaris/UltraSPARC - Linux/MIPS - * Compiling the Factor VM The Factor runtime is written in GNU C99, and is built with GNU make and gcc. -Factor requires gcc 3.4 or later. On x86, it /will not/ build using gcc -3.3 or earlier. If you are using gcc 4.3, you might get an unusable -Factor binary unless you add 'SITE_CFLAGS=-fno-forward-propagate' to the -command-line arguments for make. +Factor supports various platforms. For an up-to-date list, see +. -Run 'make' (or 'gmake' on *BSD) with no parameters to see a list of -targets and build options. Then run 'make' with the appropriate target -for your platform. +Factor requires gcc 3.4 or later. + +On x86, Factor /will not/ build using gcc 3.3 or earlier. + +If you are using gcc 4.3, you might get an unusable Factor binary unless +you add 'SITE_CFLAGS=-fno-forward-propagate' to the command-line +arguments for make. + +Run 'make' ('gmake' on *BSD) with no parameters to build the Factor VM. Compilation will yield an executable named 'factor' on Unix, -'factor-nt.exe' on Windows XP/Vista, and 'factor-ce.exe' on Windows CE. +'factor.exe' on Windows XP/Vista, and 'factor-ce.exe' on Windows CE. * Libraries needed for compilation -For X11 support, you need recent development libraries for libc, Freetype, -X11, OpenGL and GLUT. On a Debian-derived Linux distribution (like Ubuntu), -you can use the line +For X11 support, you need recent development libraries for libc, +Freetype, X11, OpenGL and GLUT. On a Debian-derived Linux distribution +(like Ubuntu), you can use the line -sudo apt-get install libc6-dev libfreetype6-dev libx11-dev glutg3-dev + sudo apt-get install libc6-dev libfreetype6-dev libx11-dev glutg3-dev -to grab everything (if you're on a non-debian-derived distro please tell us -what the equivalent command is on there and it can be added :) +to grab everything (if you're on a non-debian-derived distro please tell +us what the equivalent command is on there and it can be added). * Bootstrapping the Factor image -The boot images are no longer included with the Factor distribution -due to size concerns. Instead, download a boot image from: - - http://factorcode.org/images/ - Once you have compiled the Factor runtime, you must bootstrap the Factor system using the image that corresponds to your CPU architecture. -Once you download the right image, bootstrap the system with the +Boot images can be obtained from . + +Once you download the right image, bootstrap Factor with the following command line: ./factor -i=boot..image -Or this command for Mac OS X systems: - -./Factor.app/Contents/MacOS/factor -i=boot..image - Bootstrap can take a while, depending on your system. When the process completes, a 'factor.image' file will be generated. Note that this image is both CPU and OS-specific, so in general cannot be shared between @@ -122,9 +91,8 @@ The latter keeps the terminal listener running. * Running Factor on Mac OS X - Cocoa UI -On Mac OS X 10.4 and later, a Cocoa UI is available in addition to the -terminal listener. If you are using Mac OS X 10.3, you can only run the -X11 UI, as documented in the next section. +On Mac OS X, a Cocoa UI is available in addition to the terminal +listener. The 'factor' executable runs the terminal listener: @@ -136,17 +104,16 @@ contains factor.image and the library sources. * Running Factor on Mac OS X - X11 UI -The X11 UI is available on Mac OS X, however its use is not recommended -since it does not integrate with the host OS. However, if you are -running Mac OS X 10.3, it is your only choice. +The X11 UI is also available on Mac OS X, however its use is not +recommended since it does not integrate with the host OS. When compiling Factor, pass the X11=1 parameter: - make macosx-ppc X11=1 + make X11=1 Then bootstrap with the following switches: - ./factor -i=boot.ppc.image -ui-backend=x11 + ./factor -i=boot..image -ui-backend=x11 Now if $DISPLAY is set, running ./factor will start the UI. @@ -155,40 +122,36 @@ Now if $DISPLAY is set, running ./factor will start the UI. If you did not download the binary package, you can bootstrap Factor in the command prompt: - factor-nt.exe -i=boot.x86.32.image + factor.exe -i=boot..image Once bootstrapped, double-clicking factor.exe starts the Factor UI. To run the listener in the command prompt: - factor-nt.exe -run=listener + factor.exe -run=listener * The Factor FAQ -The Factor FAQ lives online at http://factorcode.org/faq.fhtml +The Factor FAQ is available at . * Command line usage -The Factor VM supports a number of command line switches. To read -command line usage documentation, either enter the following in the UI -listener: +Factor supports a number of command line switches. To read command line +usage documentation, enter the following in the UI listener: "command-line" about * Source organization -The following two directories are managed by the module system; consult -the documentation for details: +The Factor source tree is organized as follows: + build-support/ - scripts used for compiling Factor core/ - Factor core library and compiler extra/ - more libraries - -The following directories contain additional files: - - misc/ - editor modes, icons, etc - vm/ - sources for the Factor runtime, written in C fonts/ - TrueType fonts used by UI + misc/ - editor modes, icons, etc unmaintained/ - unmaintained contributions, please help! + vm/ - sources for the Factor VM, written in C * Community From 30b75a797a39a48714677a1fbdeff7fd2d80fb41 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 13 Apr 2008 15:06:09 -0500 Subject: [PATCH 04/26] construct-boa -> boa construct-empty -> new --- core/alien/alien.factor | 2 +- core/alien/c-types/c-types.factor | 2 +- core/alien/compiler/compiler.factor | 12 +++--- core/alien/structs/structs.factor | 2 +- core/bit-vectors/bit-vectors.factor | 2 +- core/boxes/boxes.factor | 2 +- core/byte-vectors/byte-vectors.factor | 2 +- core/classes/mixin/mixin.factor | 2 +- core/classes/tuple/tuple-docs.factor | 40 +++++++++---------- core/classes/tuple/tuple-tests.factor | 10 ++--- core/classes/tuple/tuple.factor | 2 +- core/compiler/tests/tuples.factor | 8 ++-- core/compiler/units/units.factor | 2 +- core/cpu/x86/assembler/assembler.factor | 2 +- core/dlists/dlists.factor | 2 +- core/effects/effects.factor | 2 +- core/float-vectors/float-vectors.factor | 2 +- core/generator/fixup/fixup.factor | 8 ++-- core/generator/registers/registers.factor | 8 ++-- core/generic/generic.factor | 2 +- .../standard/engines/tuple/tuple.factor | 2 +- core/generic/standard/standard-tests.factor | 16 ++++---- core/hashtables/hashtables.factor | 2 +- core/heaps/heaps.factor | 4 +- core/inference/backend/backend.factor | 4 +- core/inference/dataflow/dataflow.factor | 18 ++++----- .../transforms/transforms-tests.factor | 2 +- core/inference/transforms/transforms.factor | 6 +-- core/io/encodings/encodings.factor | 8 ++-- core/io/streams/duplex/duplex-tests.factor | 4 +- core/io/streams/duplex/duplex.factor | 2 +- core/kernel/kernel.factor | 6 +-- core/mirrors/mirrors.factor | 2 +- core/optimizer/known-words/known-words.factor | 2 +- core/optimizer/optimizer-tests.factor | 2 +- core/parser/parser.factor | 4 +- core/prettyprint/sections/sections.factor | 4 +- core/sbufs/sbufs.factor | 2 +- core/sequences/sequences.factor | 2 +- core/splitting/splitting.factor | 2 +- core/syntax/syntax-docs.factor | 6 +-- core/syntax/syntax.factor | 2 +- core/threads/threads.factor | 2 +- core/vectors/vectors.factor | 2 +- core/vocabs/vocabs.factor | 2 +- 45 files changed, 111 insertions(+), 111 deletions(-) diff --git a/core/alien/alien.factor b/core/alien/alien.factor index 2f82e5db98..f664e1175a 100755 --- a/core/alien/alien.factor +++ b/core/alien/alien.factor @@ -54,7 +54,7 @@ TUPLE: library path abi dll ; : library ( name -- library ) libraries get at ; : ( path abi -- library ) - over dup [ dlopen ] when \ library construct-boa ; + over dup [ dlopen ] when \ library boa ; : load-library ( name -- dll ) library dup [ library-dll ] when ; diff --git a/core/alien/c-types/c-types.factor b/core/alien/c-types/c-types.factor index 508fcd61a6..2e5e05f6e8 100755 --- a/core/alien/c-types/c-types.factor +++ b/core/alien/c-types/c-types.factor @@ -19,7 +19,7 @@ getter setter reg-class size align stack-align? ; : construct-c-type ( class -- type ) - construct-empty + new int-regs >>reg-class ; : ( -- type ) diff --git a/core/alien/compiler/compiler.factor b/core/alien/compiler/compiler.factor index 594c42268c..b6fcbe6176 100755 --- a/core/alien/compiler/compiler.factor +++ b/core/alien/compiler/compiler.factor @@ -220,7 +220,7 @@ M: no-such-library compiler-error-type drop +linkage+ ; : no-such-library ( name -- ) - \ no-such-library construct-boa + \ no-such-library boa compiling-word get compiler-error ; TUPLE: no-such-symbol name ; @@ -232,7 +232,7 @@ M: no-such-symbol compiler-error-type drop +linkage+ ; : no-such-symbol ( name -- ) - \ no-such-symbol construct-boa + \ no-such-symbol boa compiling-word get compiler-error ; : check-dlsym ( symbols dll -- ) @@ -251,7 +251,7 @@ M: no-such-symbol compiler-error-type \ alien-invoke [ ! Four literals 4 ensure-values - #alien-invoke construct-empty + #alien-invoke new ! Compile-time parameters pop-parameters >>parameters pop-literal nip >>function @@ -288,7 +288,7 @@ M: alien-indirect-error summary ! Three literals and function pointer 4 ensure-values 4 reify-curries - #alien-indirect construct-empty + #alien-indirect new ! Compile-time parameters pop-literal nip >>abi pop-parameters >>parameters @@ -335,7 +335,7 @@ M: alien-callback-error summary \ alien-callback [ 4 ensure-values - #alien-callback construct-empty dup node, + #alien-callback new dup node, pop-literal nip >>quot pop-literal nip >>abi pop-parameters >>parameters @@ -381,7 +381,7 @@ TUPLE: callback-context ; : wrap-callback-quot ( node -- quot ) [ [ quot>> ] [ prepare-callback-return ] bi append , - [ callback-context construct-empty do-callback ] % + [ callback-context new do-callback ] % ] [ ] make ; : %unnest-stacks ( -- ) "unnest_stacks" f %alien-invoke ; diff --git a/core/alien/structs/structs.factor b/core/alien/structs/structs.factor index 491f4351a3..6d98d31790 100755 --- a/core/alien/structs/structs.factor +++ b/core/alien/structs/structs.factor @@ -68,7 +68,7 @@ M: struct-type stack-size : (define-struct) ( name vocab size align fields -- ) >r [ align ] keep r> - struct-type construct-boa + struct-type boa -rot define-c-type ; : make-field ( struct-name vocab type field-name -- spec ) diff --git a/core/bit-vectors/bit-vectors.factor b/core/bit-vectors/bit-vectors.factor index 3949dc2632..db941ac6f7 100755 --- a/core/bit-vectors/bit-vectors.factor +++ b/core/bit-vectors/bit-vectors.factor @@ -7,7 +7,7 @@ IN: bit-vectors vector ( bit-array length -- bit-vector ) - bit-vector construct-boa ; inline + bit-vector boa ; inline PRIVATE> diff --git a/core/boxes/boxes.factor b/core/boxes/boxes.factor index a989e091bb..b56a46b6b3 100755 --- a/core/boxes/boxes.factor +++ b/core/boxes/boxes.factor @@ -5,7 +5,7 @@ IN: boxes TUPLE: box value full? ; -: ( -- box ) box construct-empty ; +: ( -- box ) box new ; : >box ( value box -- ) dup box-full? [ "Box already has a value" throw ] when diff --git a/core/byte-vectors/byte-vectors.factor b/core/byte-vectors/byte-vectors.factor index 9a0185319f..206a23f43b 100755 --- a/core/byte-vectors/byte-vectors.factor +++ b/core/byte-vectors/byte-vectors.factor @@ -7,7 +7,7 @@ IN: byte-vectors vector ( byte-array length -- byte-vector ) - byte-vector construct-boa ; inline + byte-vector boa ; inline PRIVATE> diff --git a/core/classes/mixin/mixin.factor b/core/classes/mixin/mixin.factor index 9bbe89d7d9..33b0fc32fa 100755 --- a/core/classes/mixin/mixin.factor +++ b/core/classes/mixin/mixin.factor @@ -24,7 +24,7 @@ TUPLE: check-mixin-class mixin ; : check-mixin-class ( mixin -- mixin ) dup mixin-class? [ - \ check-mixin-class construct-boa throw + \ check-mixin-class boa throw ] unless ; : if-mixin-member? ( class mixin true false -- ) diff --git a/core/classes/tuple/tuple-docs.factor b/core/classes/tuple/tuple-docs.factor index 5d35afb7d3..76165deb38 100755 --- a/core/classes/tuple/tuple-docs.factor +++ b/core/classes/tuple/tuple-docs.factor @@ -4,7 +4,7 @@ generic.standard sequences definitions compiler.units ; IN: classes.tuple ARTICLE: "parametrized-constructors" "Parameterized constructors" -"A " { $emphasis "parametrized constructor" } " is a word which directly or indirectly calls " { $link construct-empty } " or " { $link construct-boa } ", but instead of passing a literal class symbol, it takes the class symbol as an input from the stack." +"A " { $emphasis "parametrized constructor" } " is a word which directly or indirectly calls " { $link new } " or " { $link boa } ", but instead of passing a literal class symbol, it takes the class symbol as an input from the stack." $nl "Parametrized constructors are useful in many situations, in particular with subclassing. For example, consider the following code:" { $code @@ -14,14 +14,14 @@ $nl "" "TUPLE: car < vehicle engine ;" ": ( max-speed engine -- car )" - " car construct-empty" + " car new" " V{ } clone >>occupants" " swap >>engine" " swap >>max-speed ;" "" "TUPLE: aeroplane < vehicle max-altitude ;" ": ( max-speed max-altitude -- aeroplane )" - " aeroplane construct-empty" + " aeroplane new" " V{ } clone >>occupants" " swap >>max-altitude" " swap >>max-speed ;" @@ -33,7 +33,7 @@ $nl ": add-occupant ( person vehicle -- ) occupants>> push ;" "" ": construct-vehicle ( class -- vehicle )" - " construct-empty" + " new" " V{ } clone >>occupants ;" "" "TUPLE: car < vehicle engine ;" @@ -52,8 +52,8 @@ $nl ARTICLE: "tuple-constructors" "Tuple constructors" "Tuples are created by calling one of two constructor primitives:" -{ $subsection construct-empty } -{ $subsection construct-boa } +{ $subsection new } +{ $subsection boa } "A shortcut for defining BOA constructors:" { $subsection POSTPONE: C: } "By convention, construction logic is encapsulated in a word named after the tuple class surrounded in angle brackets; for example, the constructor word for a " { $snippet "point" } " class might be named " { $snippet "" } "." @@ -65,11 +65,11 @@ $nl "TUPLE: color red green blue alpha ;" "" "C: rgba" - ": color construct-boa ; ! identical to above" + ": color boa ; ! identical to above" "" ": f ;" "" - ": construct-empty ;" + ": new ;" ": f f f f ; ! identical to above" } { $subsection "parametrized-constructors" } ; @@ -129,7 +129,7 @@ $nl $nl "The second is to use ad-hoc slot polymorphism. If two classes define a slot with the same name, then code which uses " { $link "accessors" } " can operate on instances of both objects, assuming the values stored in that slot implement a common protocol. This allows code to be shared without creating contrieved relationships between classes." { $heading "Anti-pattern #3: subclassing to override a method definition" } -"While method overriding is a very powerful tool, improper use can cause tight coupling of code and lead to difficulty in testing and refactoring. Subclassing should not be used as a means of ``monkey patching'' methods to fix bugs and add features. Only subclass from classes which were designed to be inherited from, and when writing classes of your own which are intended to be subclassed, clearly document that subclasses may and may not do. This includes construction policy; document whether subclasses should use " { $link construct-empty } ", " { $link construct-boa } ", or a custom parametrized constructor." +"While method overriding is a very powerful tool, improper use can cause tight coupling of code and lead to difficulty in testing and refactoring. Subclassing should not be used as a means of ``monkey patching'' methods to fix bugs and add features. Only subclass from classes which were designed to be inherited from, and when writing classes of your own which are intended to be subclassed, clearly document that subclasses may and may not do. This includes construction policy; document whether subclasses should use " { $link new } ", " { $link boa } ", or a custom parametrized constructor." { $see-also "parametrized-constructors" } ; ARTICLE: "tuple-subclassing" "Tuple subclassing" @@ -164,11 +164,11 @@ ARTICLE: "tuple-examples" "Tuple examples" } "We can define a constructor which makes an empty employee:" { $code ": ( -- employee )" - " employee construct-empty ;" } + " employee new ;" } "Or we may wish the default constructor to always give employees a starting salary:" { $code ": ( -- employee )" - " employee construct-empty" + " employee new" " 40000 >>salary ;" } "We can define more refined constructors:" @@ -178,7 +178,7 @@ ARTICLE: "tuple-examples" "Tuple examples" "An alternative strategy is to define the most general BOA constructor first:" { $code ": ( name position -- person )" - " 40000 employee construct-boa ;" + " 40000 employee boa ;" } "Now we can define more specific constructors:" { $code @@ -191,7 +191,7 @@ ARTICLE: "tuple-examples" "Tuple examples" "SYMBOL: checks" "" ": ( to amount -- check )" - " checks counter check construct-boa ;" + " checks counter check boa ;" "" ": biweekly-paycheck ( employee -- check )" " dup name>> swap salary>> 26 / ;" @@ -326,20 +326,20 @@ HELP: tuple>array ( tuple -- array ) HELP: ( layout -- tuple ) { $values { "layout" tuple-layout } { "tuple" tuple } } -{ $description "Low-level tuple constructor. User code should never call this directly, and instead use " { $link construct-empty } "." } ; +{ $description "Low-level tuple constructor. User code should never call this directly, and instead use " { $link new } "." } ; HELP: ( ... layout -- tuple ) { $values { "..." "values" } { "layout" tuple-layout } { "tuple" tuple } } -{ $description "Low-level tuple constructor. User code should never call this directly, and instead use " { $link construct-boa } "." } ; +{ $description "Low-level tuple constructor. User code should never call this directly, and instead use " { $link boa } "." } ; -HELP: construct-empty +HELP: new { $values { "class" tuple-class } { "tuple" tuple } } { $description "Creates a new instance of " { $snippet "class" } " with all slots initially set to " { $link f } "." } { $examples { $example "USING: kernel prettyprint ;" "TUPLE: employee number name department ;" - "employee construct-empty ." + "employee new ." "T{ employee f f f f }" } } ; @@ -361,12 +361,12 @@ HELP: construct " color construct ;" } "The last definition is actually equivalent to the following:" - { $code ": ( r g b a -- color ) rgba construct-boa ;" } + { $code ": ( r g b a -- color ) rgba boa ;" } "Which can be abbreviated further:" { $code "C: color" } } ; -HELP: construct-boa +HELP: boa { $values { "..." "slot values" } { "class" tuple-class } { "tuple" tuple } } { $description "Creates a new instance of " { $snippet "class" } " and fill in the slots from the stack, with the top-most stack element being stored in the right-most slot." } -{ $notes "The " { $snippet "-boa" } " suffix is shorthand for ``by order of arguments'', and ``BOA constructor'' is a pun on ``boa constrictor''." } ; +{ $notes "The name " { $snippet "boa" } " is shorthand for ``by order of arguments'', and ``BOA constructor'' is a pun on ``boa constrictor''." } ; diff --git a/core/classes/tuple/tuple-tests.factor b/core/classes/tuple/tuple-tests.factor index 2575570d2f..b34491ead6 100755 --- a/core/classes/tuple/tuple-tests.factor +++ b/core/classes/tuple/tuple-tests.factor @@ -7,7 +7,7 @@ calendar prettyprint io.streams.string splitting inspector ; IN: classes.tuple.tests TUPLE: rect x y w h ; -: rect construct-boa ; +: rect boa ; : move ( x rect -- rect ) [ + ] change-x ; @@ -198,8 +198,8 @@ SYMBOL: not-a-tuple-class ] unit-test ! Missing check -[ not-a-tuple-class construct-boa ] must-fail -[ not-a-tuple-class construct-empty ] must-fail +[ not-a-tuple-class boa ] must-fail +[ not-a-tuple-class new ] must-fail TUPLE: erg's-reshape-problem a b c d ; @@ -207,8 +207,8 @@ C: erg's-reshape-problem ! We want to make sure constructors are recompiled when ! tuples are reshaped -: cons-test-1 \ erg's-reshape-problem construct-empty ; -: cons-test-2 \ erg's-reshape-problem construct-boa ; +: cons-test-1 \ erg's-reshape-problem new ; +: cons-test-2 \ erg's-reshape-problem boa ; "IN: classes.tuple.tests TUPLE: erg's-reshape-problem a b c d e f ;" eval diff --git a/core/classes/tuple/tuple.factor b/core/classes/tuple/tuple.factor index aa8ef6cdb7..8d5c4ee2d8 100755 --- a/core/classes/tuple/tuple.factor +++ b/core/classes/tuple/tuple.factor @@ -199,7 +199,7 @@ M: tuple-class define-tuple-class : define-error-class ( class superclass slots -- ) [ define-tuple-class ] [ 2drop ] 3bi - dup [ construct-boa throw ] curry define ; + dup [ boa throw ] curry define ; M: tuple-class reset-class [ diff --git a/core/compiler/tests/tuples.factor b/core/compiler/tests/tuples.factor index 97cde6261c..2b43ac6f56 100755 --- a/core/compiler/tests/tuples.factor +++ b/core/compiler/tests/tuples.factor @@ -4,16 +4,16 @@ USING: kernel tools.test compiler.units ; TUPLE: color red green blue ; [ T{ color f 1 2 3 } ] -[ 1 2 3 [ color construct-boa ] compile-call ] unit-test +[ 1 2 3 [ color boa ] compile-call ] unit-test [ 1 3 ] [ - 1 2 3 color construct-boa + 1 2 3 color boa [ { color-red color-blue } get-slots ] compile-call ] unit-test [ T{ color f 10 2 20 } ] [ 10 20 - 1 2 3 color construct-boa [ + 1 2 3 color boa [ [ { set-color-red set-color-blue } set-slots ] compile-call @@ -21,4 +21,4 @@ TUPLE: color red green blue ; ] unit-test [ T{ color f f f f } ] -[ [ color construct-empty ] compile-call ] unit-test +[ [ color new ] compile-call ] unit-test diff --git a/core/compiler/units/units.factor b/core/compiler/units/units.factor index 58300b721a..65e57a8912 100755 --- a/core/compiler/units/units.factor +++ b/core/compiler/units/units.factor @@ -10,7 +10,7 @@ SYMBOL: new-definitions TUPLE: redefine-error def ; : redefine-error ( definition -- ) - \ redefine-error construct-boa + \ redefine-error boa { { "Continue" t } } throw-restarts drop ; : add-once ( key assoc -- ) diff --git a/core/cpu/x86/assembler/assembler.factor b/core/cpu/x86/assembler/assembler.factor index 450aa8f980..3ad7d4f7b5 100755 --- a/core/cpu/x86/assembler/assembler.factor +++ b/core/cpu/x86/assembler/assembler.factor @@ -104,7 +104,7 @@ M: indirect extended? indirect-base extended? ; canonicalize-ESP ; : ( base index scale displacement -- indirect ) - indirect construct-boa dup canonicalize ; + indirect boa dup canonicalize ; : reg-code "register" word-prop 7 bitand ; diff --git a/core/dlists/dlists.factor b/core/dlists/dlists.factor index b4ae207455..e79907f11f 100755 --- a/core/dlists/dlists.factor +++ b/core/dlists/dlists.factor @@ -7,7 +7,7 @@ IN: dlists TUPLE: dlist front back length ; : ( -- obj ) - dlist construct-empty + dlist new 0 >>length ; : dlist-empty? ( dlist -- ? ) front>> not ; diff --git a/core/effects/effects.factor b/core/effects/effects.factor index 7da290992c..80a4f679c0 100755 --- a/core/effects/effects.factor +++ b/core/effects/effects.factor @@ -8,7 +8,7 @@ TUPLE: effect in out terminated? ; : ( in out -- effect ) dup { "*" } sequence= [ drop { } t ] [ f ] if - effect construct-boa ; + effect boa ; : effect-height ( effect -- n ) dup effect-out length swap effect-in length - ; diff --git a/core/float-vectors/float-vectors.factor b/core/float-vectors/float-vectors.factor index 11535e349e..7f62f6f95c 100755 --- a/core/float-vectors/float-vectors.factor +++ b/core/float-vectors/float-vectors.factor @@ -7,7 +7,7 @@ IN: float-vectors vector ( float-array length -- float-vector ) - float-vector construct-boa ; inline + float-vector boa ; inline PRIVATE> diff --git a/core/generator/fixup/fixup.factor b/core/generator/fixup/fixup.factor index 3a5a6571b7..920690e9d8 100755 --- a/core/generator/fixup/fixup.factor +++ b/core/generator/fixup/fixup.factor @@ -10,7 +10,7 @@ IN: generator.fixup TUPLE: frame-required n ; -: frame-required ( n -- ) \ frame-required construct-boa , ; +: frame-required ( n -- ) \ frame-required boa , ; : stack-frame-size ( code -- n ) no-stack-frame [ @@ -25,7 +25,7 @@ GENERIC: fixup* ( frame-size obj -- frame-size ) TUPLE: label offset ; -: