From: Doug Coleman Date: Wed, 20 Jun 2018 00:15:05 +0000 (-0500) Subject: core: Add the shuffler words but without primitives. X-Git-Tag: 0.98~87 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=9f213f96f6589534d2ed5b3875ca05386b9afd5e core: Add the shuffler words but without primitives. The nipd branch slowed bootstrap by a minute, this patch does not. sorry about changing the fjsc line endings... --- diff --git a/basis/alien/libraries/libraries.factor b/basis/alien/libraries/libraries.factor index 2365e0ee42..a176e106e4 100755 --- a/basis/alien/libraries/libraries.factor +++ b/basis/alien/libraries/libraries.factor @@ -65,7 +65,7 @@ M: library dispose dll>> [ dispose ] when* ; : add-library ( name path abi -- ) 3dup add-library? [ [ 2drop remove-library ] - [ [ nip ] dip make-library ] + [ nipd make-library ] [ 2drop libraries get set-at ] 3tri ] [ 3drop ] if ; diff --git a/basis/calendar/parser/parser.factor b/basis/calendar/parser/parser.factor index b61ec74fb0..648115a1fb 100644 --- a/basis/calendar/parser/parser.factor +++ b/basis/calendar/parser/parser.factor @@ -104,7 +104,7 @@ CONSTANT: rfc822-named-zones H{ read1 CHAR: \s assert= read-sp checked-number read-sp month-abbreviations index 1 + check-timestamp - read-sp checked-number -rot swap + read-sp checked-number spin read-hh:mm:ss " " read-until drop parse-rfc822-gmt-offset ; @@ -120,7 +120,7 @@ CONSTANT: rfc822-named-zones H{ read1 CHAR: \s assert= "-" read-token checked-number "-" read-token month-abbreviations index 1 + check-timestamp - read-sp checked-number -rot swap + read-sp checked-number spin read-hh:mm:ss " " read-until drop parse-rfc822-gmt-offset ; diff --git a/basis/checksums/ripemd/ripemd.factor b/basis/checksums/ripemd/ripemd.factor index b5f05b57cc..dde039c792 100644 --- a/basis/checksums/ripemd/ripemd.factor +++ b/basis/checksums/ripemd/ripemd.factor @@ -39,7 +39,7 @@ M: ripemd-160 initialize-checksum-state drop ; : F ( x y z -- out ) bitxor bitxor ; inline : G ( x y z -- out ) pick bitnot swap [ bitand ] 2bi@ bitor ; inline : H ( x y z -- out ) [ bitnot bitor ] [ bitxor ] bi* ; inline -: I ( x y z -- out ) swap over bitnot [ bitand ] 2bi@ bitor ; inline +: I ( x y z -- out ) tuck bitnot [ bitand ] 2bi@ bitor ; inline : J ( x y z -- out ) bitnot bitor bitxor ; inline CONSTANT: T11 0x00000000 diff --git a/basis/checksums/sha/sha-tests.factor b/basis/checksums/sha/sha-tests.factor index ef211821d6..8ef558bb0b 100644 --- a/basis/checksums/sha/sha-tests.factor +++ b/basis/checksums/sha/sha-tests.factor @@ -84,7 +84,7 @@ CONSTANT: bytes-b B{ 1 2 3 4 5 6 7 8 } ERROR: checksums-differ algorithm seq incremental-checksum one-go-checksum ; : compare-checksum-calculations ( algorithm seq -- ? ) 2dup [ incremental-checksum ] [ one-go-checksum ] 2bi 2dup = [ - 2drop 2drop t + 4drop t ] [ checksums-differ ] if ; diff --git a/basis/classes/struct/struct.factor b/basis/classes/struct/struct.factor index e09b3ddfed..5a39fb607e 100644 --- a/basis/classes/struct/struct.factor +++ b/basis/classes/struct/struct.factor @@ -135,7 +135,7 @@ PRIVATE> M: struct-class boa>object swap pad-struct-slots [ ] [ struct-slots ] bi - [ [ (writer-quot) call( value struct -- ) ] with 2each ] curry keep ; + [ [ (writer-quot) call( value struct -- ) ] with 2each ] keepd ; M: struct-class initial-value* t ; inline @@ -262,7 +262,7 @@ M: struct binary-zero? binary-object uchar [ 0 = ] all? ; inlin [ [ initial>> ] [ (writer-quot) ] bi - over [ swapd [ call( value struct -- ) ] curry keep ] [ 2drop ] if + over [ swapd [ call( value struct -- ) ] keepd ] [ 2drop ] if ] each ] [ drop f ] if ; diff --git a/basis/compiler/cfg/linear-scan/assignment/assignment.factor b/basis/compiler/cfg/linear-scan/assignment/assignment.factor index 345d11b567..b5ffb4d0ee 100644 --- a/basis/compiler/cfg/linear-scan/assignment/assignment.factor +++ b/basis/compiler/cfg/linear-scan/assignment/assignment.factor @@ -102,7 +102,7 @@ RENAMING: assign [ vreg>reg ] [ vreg>reg ] [ vreg>reg ] } cleave ; : change-insn-gc-roots ( gc-map-insn quot: ( x -- x ) -- ) - [ gc-map>> ] dip [ swap gc-roots>> swap map! drop ] + [ gc-map>> ] dip [ [ gc-roots>> ] dip map! drop ] [ '[ [ _ bi@ ] assoc-map ] change-derived-roots drop ] 2bi ; inline : spill-required? ( live-interval root-leaders n -- ? ) diff --git a/basis/compiler/cfg/stacks/local/local-tests.factor b/basis/compiler/cfg/stacks/local/local-tests.factor index 6f5ac9c81e..83135d186d 100644 --- a/basis/compiler/cfg/stacks/local/local-tests.factor +++ b/basis/compiler/cfg/stacks/local/local-tests.factor @@ -146,7 +146,7 @@ IN: compiler.cfg.stacks.local.tests : my-new-key4 ( a i j -- i/j ) 2over slot - swap over + tuck ! a i el j el [ ! a i el j diff --git a/basis/compiler/cfg/stacks/stacks.factor b/basis/compiler/cfg/stacks/stacks.factor index 9b6e3aef99..3dcf5bd525 100644 --- a/basis/compiler/cfg/stacks/stacks.factor +++ b/basis/compiler/cfg/stacks/stacks.factor @@ -21,7 +21,7 @@ IN: compiler.cfg.stacks } apply-passes ; : create-locs ( loc-class seq -- locs ) - [ swap new swap >>n ] with map ; + [ [ new ] dip >>n ] with map ; : stack-locs ( loc-class n -- locs ) create-locs ; diff --git a/basis/compiler/cfg/value-numbering/simd/simd.factor b/basis/compiler/cfg/value-numbering/simd/simd.factor index 1c0e8ac88c..adff45b5e5 100644 --- a/basis/compiler/cfg/value-numbering/simd/simd.factor +++ b/basis/compiler/cfg/value-numbering/simd/simd.factor @@ -85,8 +85,8 @@ M: ##gather-int-vector-2 rewrite rewrite-gather-vector-2 ; : rewrite-gather-vector-4 ( insn -- insn/f ) dup { [ src1>> ] [ src2>> ] [ src3>> ] [ src4>> ] } cleave [ vreg>insn ] 4 napply { - { [ 4 ndup [ literal-insn? ] 4 napply and and and ] [ fold-gather-vector-4 ] } - [ 5 ndrop f ] + { [ 4dup [ literal-insn? ] 4 napply and and and ] [ fold-gather-vector-4 ] } + [ 5drop f ] } cond ; M: ##gather-vector-4 rewrite rewrite-gather-vector-4 ; diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index 08fdcf8761..3e4f149077 100755 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -151,7 +151,7 @@ unit-test : multi_ffi_test_18 ( w x y z w' x' y' z' -- int int ) [ int "f-stdcall" "ffi_test_18" { int int int int } f alien-invoke ] - 4 ndip + 4dip int "f-stdcall" "ffi_test_18" { int int int int } f alien-invoke gc ; @@ -917,11 +917,11 @@ FUNCTION: void* bug1021_test_1 ( void* s, int x ) ] [ 2drop ] if ; inline recursive : run-test ( alien -- seq ) - 100 33 swap over + 100 33 tuck [ pick swapd bug1021_test_1 - -rot swap 2 fixnum+fast + spin 2 fixnum+fast set-slot ] curry curry 0 each-to100 ; diff --git a/basis/compiler/tree/propagation/simd/simd.factor b/basis/compiler/tree/propagation/simd/simd.factor index dc4b852017..5e0ab5a94f 100644 --- a/basis/compiler/tree/propagation/simd/simd.factor +++ b/basis/compiler/tree/propagation/simd/simd.factor @@ -124,7 +124,7 @@ vector>vector-intrinsics [ { byte-array } "default-output-classes" set-word-prop : inline-unless-intrinsic ( word -- ) dup '[ - _ swap over "intrinsic" word-prop + _ tuck "intrinsic" word-prop "always-inline-simd-intrinsics" get not swap and ! word node intrinsic [ try-intrinsic [ drop f ] [ def>> ] if ] diff --git a/basis/compression/snappy/snappy.factor b/basis/compression/snappy/snappy.factor index 590c9d4b71..5437897f32 100644 --- a/basis/compression/snappy/snappy.factor +++ b/basis/compression/snappy/snappy.factor @@ -29,4 +29,4 @@ PRIVATE> [ snappy_uncompressed_length check-snappy ] keep size_t deref n>outs - [ snappy_uncompress check-snappy ] 2keep drop >byte-array ; + [ snappy_uncompress check-snappy ] keepd >byte-array ; diff --git a/basis/compression/zlib/zlib.factor b/basis/compression/zlib/zlib.factor index f258097a5c..1fb31cc54b 100644 --- a/basis/compression/zlib/zlib.factor +++ b/basis/compression/zlib/zlib.factor @@ -37,7 +37,7 @@ ERROR: zlib-failed n string ; [ dup underlying>> ] keep ulong ] keep [ dup length compression.zlib.ffi:compress zlib-error - ] 2keep drop ulong deref >>length B{ } like ; + ] keepd ulong deref >>length B{ } like ; : (uncompress) ( length byte-array -- byte-array ) [ @@ -53,15 +53,13 @@ ERROR: zlib-failed n string ; : zlib-inflate-init ( -- z_stream_s ) - z_stream ZLIB_VERSION over byte-length [ - inflateInit_ zlib-error - ] 3keep 2drop ; + z_stream + dup ZLIB_VERSION over byte-length inflateInit_ zlib-error ; ! window can be 0, 15, 32, 47 (others?) : zlib-inflate-init2 ( window -- z_stream_s ) - [ z_stream ] dip ZLIB_VERSION pick byte-length [ - inflateInit2_ zlib-error - ] 4keep 3drop ; + [ z_stream dup ] dip + ZLIB_VERSION pick byte-length inflateInit2_ zlib-error ; : zlib-inflate-end ( z_stream -- ) inflateEnd zlib-error ; @@ -73,6 +71,4 @@ ERROR: zlib-failed n string ; inflate zlib-error ; : zlib-inflate-get-header ( z_stream -- gz_header ) - gz_header [ - inflateGetHeader zlib-error - ] keep ; + gz_header [ inflateGetHeader zlib-error ] keep ; diff --git a/basis/cpu/ppc/assembler/assembler.factor b/basis/cpu/ppc/assembler/assembler.factor index 36f737154a..9d37f1cdd6 100644 --- a/basis/cpu/ppc/assembler/assembler.factor +++ b/basis/cpu/ppc/assembler/assembler.factor @@ -1949,8 +1949,8 @@ tri* 134 1 63 x-insn ; : CLRLDI. ( ra rs n -- ) 0 swap RLDICL. ; : CLRRDI ( ra rs n -- ) 0 swap 63 swap - RLDICR ; : CLRRDI. ( ra rs n -- ) 0 swap 63 swap - RLDICR. ; -: CLRLSLDI ( ra rs b n -- ) swap over - RLDIC ; -: CLRLSLDI. ( ra rs b n -- ) swap over - RLDIC. ; +: CLRLSLDI ( ra rs b n -- ) tuck - RLDIC ; +: CLRLSLDI. ( ra rs b n -- ) tuck - RLDIC. ; ! E.7.2 Operations on Words : EXTLWI ( ra rs n b -- ) swap 0 1 - RLWINM ; diff --git a/basis/cpu/x86/assembler/assembler.factor b/basis/cpu/x86/assembler/assembler.factor index 2d5b77fd73..1670db2f59 100644 --- a/basis/cpu/x86/assembler/assembler.factor +++ b/basis/cpu/x86/assembler/assembler.factor @@ -147,7 +147,7 @@ M: register displacement, drop ; : 1-operand ( operand reg,rex.w,opcode -- ) ! The 'reg' is not really a register, but a value for the ! 'reg' field of the mod-r/m byte. - first3 [ [ over ] dip prefix-1 ] dip opcode, swap addressing ; + first3 [ overd prefix-1 ] dip opcode, swap addressing ; : immediate-operand-size-bit ( dst imm reg,rex.w,opcode -- imm dst reg,rex.w,opcode ) over integer? [ first3 0b1 opcode-or 3array ] when ; diff --git a/basis/cpu/x86/x86.factor b/basis/cpu/x86/x86.factor index 6a6e5dca3f..e823ad72b5 100644 --- a/basis/cpu/x86/x86.factor +++ b/basis/cpu/x86/x86.factor @@ -409,7 +409,7 @@ M: x86 %convert-integer ( dst src c-type -- ) { c:int [ 32 %alien-signed-getter ] } { c:uint [ 32 [ 2drop ] %alien-integer-getter ] } } case - ] [ [ drop ] 2dip %copy ] ?if ; + ] [ nipd %copy ] ?if ; M: x86 %load-memory ( dst base displacement scale offset rep c-type -- ) (%memory) (%load-memory) ; diff --git a/basis/csv/csv.factor b/basis/csv/csv.factor index fb34233c64..bf42a0a6eb 100644 --- a/basis/csv/csv.factor +++ b/basis/csv/csv.factor @@ -17,7 +17,7 @@ MEMO: field-delimiters ( delimiter -- field-seps quote-seps ) DEFER: quoted-field, : maybe-escaped-quote ( delimeter stream quoted? -- delimiter stream sep/f ) - 2over stream-read1 swap over = + 2over stream-read1 tuck = [ nip ] [ { { CHAR: \" [ [ CHAR: \" , ] when quoted-field, ] } @@ -42,12 +42,12 @@ DEFER: quoted-field, : continue-field ( delimiter stream field-seps seq -- sep/f field ) swap rot stream-read-until [ "\"" glue ] dip - swap ?trim [ drop ] 2dip ; inline + swap ?trim nipd ; inline : field ( delimiter stream field-seps quote-seps -- sep/f field ) pick stream-read-until dup CHAR: \" = [ drop [ drop quoted-field ] [ continue-field ] if-empty - ] [ [ 3drop ] 2dip swap ?trim ] if ; + ] [ 3nipd swap ?trim ] if ; : (stream-read-row) ( delimiter stream field-end quoted-field -- sep/f fields ) [ [ dup '[ dup _ = ] ] keep ] 3dip @@ -61,7 +61,7 @@ DEFER: quoted-field, PRIVATE> : stream-read-row ( stream -- row ) - delimiter get swap over field-delimiters + delimiter get tuck field-delimiters (stream-read-row) nip ; inline : read-row ( -- row ) diff --git a/basis/db/postgresql/lib/lib.factor b/basis/db/postgresql/lib/lib.factor index d4ad6dd18a..5a51dc0e12 100644 --- a/basis/db/postgresql/lib/lib.factor +++ b/basis/db/postgresql/lib/lib.factor @@ -118,7 +118,7 @@ M: postgresql-result-null summary ( obj -- str ) : pq-get-string ( handle row column -- obj ) 3dup PQgetvalue utf8 alien>string - dup empty? [ [ pq-get-is-null f ] dip ? ] [ [ 3drop ] dip ] if ; + dup empty? [ [ pq-get-is-null f ] dip ? ] [ 3nip ] if ; : pq-get-number ( handle row column -- obj ) pq-get-string dup [ string>number ] when ; @@ -135,7 +135,7 @@ M: postgresql-malloc-destructor dispose ( obj -- ) : pq-get-blob ( handle row column -- obj/f ) [ PQgetvalue ] 3keep 3dup PQgetlength dup 0 > [ - [ 3drop ] dip + 3nip [ memory>byte-array >string { uint } diff --git a/basis/formatting/formatting.factor b/basis/formatting/formatting.factor index f4e0a4a1ee..5b9b722f89 100644 --- a/basis/formatting/formatting.factor +++ b/basis/formatting/formatting.factor @@ -37,7 +37,7 @@ ERROR: unknown-format-directive value ; [ 10^ * round-to-even >integer number>string ] [ 1 + CHAR: 0 pad-head ] [ cut* ] tri [ "." glue ] unless-empty - ] curry keep neg? [ CHAR: - prefix ] when ; + ] keepd neg? [ CHAR: - prefix ] when ; : format-scientific-mantissa ( x log10x digits -- string rounded-up? ) [ swap - 10^ * round-to-even >integer number>string ] keep @@ -55,7 +55,7 @@ ERROR: unknown-format-directive value ; [ abs dup integer-log10 ] dip [ format-scientific-mantissa ] [ drop nip format-scientific-exponent ] 3bi append - ] curry keep neg? [ CHAR: - prefix ] when ; + ] keepd neg? [ CHAR: - prefix ] when ; : format-float-fast ( x digits string -- string ) [ "" -1 ] 2dip "C" format-float ; diff --git a/basis/fry/fry.factor b/basis/fry/fry.factor index cca4aef3b5..27292e7012 100644 --- a/basis/fry/fry.factor +++ b/basis/fry/fry.factor @@ -110,7 +110,7 @@ TUPLE: dredge-fry-state : in-quot-slices ( n i state -- head tail ) in-quot>> [ ] - [ [ drop ] 2dip swap 1 + tail-slice ] 3bi ; inline + [ nipd swap 1 + tail-slice ] 3bi ; inline : push-head-slice ( head state -- ) quot>> [ push-all ] [ \ _ swap push ] bi ; inline @@ -122,7 +122,7 @@ TUPLE: dredge-fry-state rot { [ nip in-quot-slices ] ! head tail i elt state [ [ 2drop swap ] dip push-head-slice ] - [ [ drop ] 2dip push-subquot ] + [ nipd push-subquot ] [ [ 1 + ] [ drop ] [ ] tri* dredge-fry ] } 3cleave ; inline recursive diff --git a/basis/furnace/chloe-tags/chloe-tags.factor b/basis/furnace/chloe-tags/chloe-tags.factor index fc7f826bc4..94f507c733 100644 --- a/basis/furnace/chloe-tags/chloe-tags.factor +++ b/basis/furnace/chloe-tags/chloe-tags.factor @@ -32,7 +32,7 @@ IN: furnace.chloe-tags [ [ "/" ?tail drop "/" ] dip present 3append ] when* ; : a-url ( href rest query value-name -- url ) - dup [ [ 3drop ] dip value ] [ + dup [ 3nip value ] [ drop swap parse-query-attr >>query diff --git a/basis/game/input/dinput/dinput.factor b/basis/game/input/dinput/dinput.factor index f2aaff1656..78b8ac5444 100755 --- a/basis/game/input/dinput/dinput.factor +++ b/basis/game/input/dinput/dinput.factor @@ -176,7 +176,7 @@ SYMBOLS: +dinput+ +keyboard-device+ +keyboard-state+ DEV_BROADCAST_HDR memory>struct ; : handle-wm-devicechange ( hWnd uMsg wParam lParam -- ) - [ 2drop ] 2dip swap { + 2nipd swap { { [ dup DBT_DEVICEARRIVAL = ] [ drop device-arrived ] } { [ dup DBT_DEVICEREMOVECOMPLETE = ] [ drop device-removed ] } [ 2drop ] diff --git a/basis/game/input/gtk/gtk.factor b/basis/game/input/gtk/gtk.factor index 607c7d6ffc..8801610ddd 100644 --- a/basis/game/input/gtk/gtk.factor +++ b/basis/game/input/gtk/gtk.factor @@ -98,7 +98,7 @@ M: gtk-game-input-backend read-keyboard get-dpy dup XDefaultRootWindow { int int int int int int int } [ XQueryPointer drop ] with-out-parameters - [ 4 ndrop ] 3dip ; + [ 4drop ] 3dip ; M: gtk-game-input-backend read-mouse query-pointer diff --git a/basis/game/input/x11/x11.factor b/basis/game/input/x11/x11.factor index 612b0047bf..eb1273ed80 100644 --- a/basis/game/input/x11/x11.factor +++ b/basis/game/input/x11/x11.factor @@ -90,7 +90,7 @@ M: x11-game-input-backend read-keyboard dpy get dup XDefaultRootWindow { int int int int int int int } [ XQueryPointer drop ] with-out-parameters - [ 4 ndrop ] 3dip ; + [ 4drop ] 3dip ; SYMBOL: mouse-reset? diff --git a/basis/grouping/grouping.factor b/basis/grouping/grouping.factor index e2309d9884..0edcb3d80b 100644 --- a/basis/grouping/grouping.factor +++ b/basis/grouping/grouping.factor @@ -61,7 +61,7 @@ M: clumps group@ diff --git a/basis/heaps/heaps.factor b/basis/heaps/heaps.factor index a1fe479f77..f4490fb620 100644 --- a/basis/heaps/heaps.factor +++ b/basis/heaps/heaps.factor @@ -60,7 +60,7 @@ M: heap heap-size ( heap -- n ) : data-push ( entry data -- n ) [ length [ >>index ] keep ] - [ [ set-nth ] 2keep drop ] bi ; inline + [ [ set-nth ] keepd ] bi ; inline GENERIC: heap-compare ( entry1 entry2 heap -- ? ) diff --git a/basis/help/lint/checks/checks.factor b/basis/help/lint/checks/checks.factor index 8e3d73487d..fef85e3358 100644 --- a/basis/help/lint/checks/checks.factor +++ b/basis/help/lint/checks/checks.factor @@ -83,6 +83,7 @@ SYMBOL: vocab-articles ] map ; : contains-funky-elements? ( element -- ? ) +B { $shuffle $complex-shuffle diff --git a/basis/inverse/inverse.factor b/basis/inverse/inverse.factor index 0a75bdf31f..2407a78dfa 100644 --- a/basis/inverse/inverse.factor +++ b/basis/inverse/inverse.factor @@ -259,7 +259,7 @@ DEFER: __ : recover-fail ( try fail -- ) [ drop call ] [ - [ nip ] dip dup fail? + nipd dup fail? [ drop call ] [ nip throw ] if ] recover ; inline diff --git a/basis/io/backend/unix/multiplexers/epoll/epoll.factor b/basis/io/backend/unix/multiplexers/epoll/epoll.factor index ba5802fc7c..9921b483f5 100644 --- a/basis/io/backend/unix/multiplexers/epoll/epoll.factor +++ b/basis/io/backend/unix/multiplexers/epoll/epoll.factor @@ -23,7 +23,7 @@ M: epoll-mx dispose* fd>> close-file ; : make-event ( fd events -- event ) epoll-event swap >>events - swap over data>> fd<< ; + tuck data>> fd<< ; :: do-epoll-ctl ( fd mx what events -- ) mx fd>> what fd fd events make-event epoll_ctl io-error ; diff --git a/basis/io/buffers/buffers.factor b/basis/io/buffers/buffers.factor index fed9a480a3..72d7f4c474 100644 --- a/basis/io/buffers/buffers.factor +++ b/basis/io/buffers/buffers.factor @@ -56,7 +56,7 @@ TYPED: buffer-read-into ( dst n: fixnum buffer: buffer -- count ) pick c-ptr? [ memcpy ] [ - -rot swap + spin [ swap alien-unsigned-1 ] [ set-nth-unsafe ] bi-curry* [ bi ] 2curry each-integer diff --git a/basis/io/encodings/utf32/utf32.factor b/basis/io/encodings/utf32/utf32.factor index 025b74103e..005922c31a 100644 --- a/basis/io/encodings/utf32/utf32.factor +++ b/basis/io/encodings/utf32/utf32.factor @@ -20,29 +20,25 @@ utf32 "UTF-32" register-encoding ! Decoding -: char> ( stream encoding quot -- ch ) - nip swap 4 swap stream-read dup length { +: char> ( stream quot -- ch ) + swap [ 4 ] dip stream-read dup length { { 0 [ 2drop f ] } { 4 [ swap call ] } [ 3drop replacement-char ] } case ; inline -M: utf32be decode-char - [ be> ] char> ; +M: utf32be decode-char drop [ be> ] char> ; -M: utf32le decode-char - [ le> ] char> ; +M: utf32le decode-char drop [ le> ] char> ; ! Encoding -: >char ( char stream encoding quot -- ) - nip 4 swap curry dip stream-write ; inline +: >char ( char stream quot -- ) + 4 swap curry dip stream-write ; inline -M: utf32be encode-char - [ >be ] >char ; +M: utf32be encode-char drop [ >be ] >char ; -M: utf32le encode-char - [ >le ] >char ; +M: utf32le encode-char drop [ >le ] >char ; ! UTF-32 @@ -51,7 +47,9 @@ CONSTANT: bom-le B{ 0xff 0xfe 0 0 } CONSTANT: bom-be B{ 0 0 0xfe 0xff } : bom>le/be ( bom -- le/be ) - dup bom-le sequence= [ drop utf32le ] [ + dup bom-le sequence= [ + drop utf32le + ] [ bom-be sequence= [ utf32be ] [ missing-bom ] if ] if ; diff --git a/basis/io/files/windows/windows.factor b/basis/io/files/windows/windows.factor index 566f8c7a8c..556bbfc4ee 100755 --- a/basis/io/files/windows/windows.factor +++ b/basis/io/files/windows/windows.factor @@ -388,7 +388,7 @@ M: windows home FindStreamInfoStandard WIN32_FIND_STREAM_DATA 0 - [ FindFirstStream ] 2keep drop + [ FindFirstStream ] keepd over -1 = [ 2drop throw-win32-error ] [ diff --git a/basis/io/ports/ports.factor b/basis/io/ports/ports.factor index 77b54d7192..f37eb23a6c 100644 --- a/basis/io/ports/ports.factor +++ b/basis/io/ports/ports.factor @@ -89,25 +89,25 @@ M: input-port stream-read-unsafe : read-until-loop ( seps port accum -- sep/f ) 2over read-until-step over [ [ append! ] dip dup [ - [ 3drop ] dip + 3nip ] [ drop read-until-loop ] if ] [ - [ 4drop ] dip + 4nip ] if ; inline recursive PRIVATE> M: input-port stream-read-until 2dup read-until-step dup [ - [ 2drop ] 2dip + 2nipd ] [ over [ drop BV{ } like [ read-until-loop ] keep B{ } like swap ] [ - [ 2drop ] 2dip + 2nipd ] if ] if ; diff --git a/basis/io/sockets/secure/openssl/openssl.factor b/basis/io/sockets/secure/openssl/openssl.factor index 7ee03d3adf..f23c635804 100644 --- a/basis/io/sockets/secure/openssl/openssl.factor +++ b/basis/io/sockets/secure/openssl/openssl.factor @@ -238,7 +238,7 @@ SYMBOL: default-secure-context ] [ nip (ssl-error) ] if-zero ; : check-ssl-error ( ssl ret exra-cases/f -- event/f ) - [ swap over SSL_get_error ] dip + [ tuck SSL_get_error ] dip { { SSL_ERROR_NONE [ drop f ] } { SSL_ERROR_WANT_READ [ drop +input+ ] } diff --git a/basis/io/sockets/unix/unix.factor b/basis/io/sockets/unix/unix.factor index 0617c5ed1f..fbb5515d2f 100644 --- a/basis/io/sockets/unix/unix.factor +++ b/basis/io/sockets/unix/unix.factor @@ -40,11 +40,11 @@ M: unix addrspec-of-family ! Client sockets - TCP and Unix domain M: object (get-local-address) [ handle-fd ] dip empty-sockaddr/size int - [ getsockname io-error ] 2keep drop ; + [ getsockname io-error ] keepd ; M: object (get-remote-address) [ handle-fd ] dip empty-sockaddr/size int - [ getpeername io-error ] 2keep drop ; + [ getpeername io-error ] keepd ; : init-client-socket ( fd -- ) SOL_SOCKET SO_OOBINLINE set-socket-option ; @@ -94,7 +94,7 @@ M: object (server) : do-accept ( server addrspec -- fd sockaddr ) [ handle>> handle-fd ] [ empty-sockaddr/size int ] bi* - [ unix.ffi:accept ] 2keep drop ; inline + [ unix.ffi:accept ] keepd ; inline M: object (accept) 2dup do-accept over 0 >= [ @@ -133,7 +133,7 @@ M: unix (broadcast) recvfrom sockaddr ; inline : (receive-loop) ( n buf datagram -- count sockaddr ) - 3dup do-receive over 0 > [ [ 3drop ] 2dip ] [ + 3dup do-receive over 0 > [ 3nipd ] [ 2drop [ +input+ wait-for-port ] [ (receive-loop) ] bi ] if ; inline recursive diff --git a/basis/io/sockets/windows/windows.factor b/basis/io/sockets/windows/windows.factor index e9ca95a544..9651b7917f 100755 --- a/basis/io/sockets/windows/windows.factor +++ b/basis/io/sockets/windows/windows.factor @@ -56,11 +56,11 @@ M: win32-socket dispose* ( stream -- ) M: object (get-local-address) ( socket addrspec -- sockaddr ) [ handle>> ] dip empty-sockaddr/size int - [ getsockname socket-error ] 2keep drop ; + [ getsockname socket-error ] keepd ; M: object (get-remote-address) ( socket addrspec -- sockaddr ) [ handle>> ] dip empty-sockaddr/size int - [ getpeername socket-error ] 2keep drop ; + [ getpeername socket-error ] keepd ; : bind-socket ( win32-socket sockaddr len -- ) [ handle>> ] 2dip bind socket-error ; diff --git a/basis/libc/macosx/macosx.factor b/basis/libc/macosx/macosx.factor index 70388535c1..5221846fa7 100644 --- a/basis/libc/macosx/macosx.factor +++ b/basis/libc/macosx/macosx.factor @@ -145,6 +145,6 @@ FUNCTION: int strerror_r ( int errno, char* buf, size_t buflen ) M: macosx strerror ( errno -- str ) [ - 1024 [ malloc &free ] keep [ strerror_r ] 2keep drop nip + 1024 [ malloc &free ] keep [ strerror_r ] keepd nip alien>native-string ] with-destructors ; diff --git a/basis/libc/windows/windows.factor b/basis/libc/windows/windows.factor index b328df3ff9..449031882d 100644 --- a/basis/libc/windows/windows.factor +++ b/basis/libc/windows/windows.factor @@ -111,6 +111,6 @@ FUNCTION: int strerror_s ( char *buffer, size_t numberOfElements, int errnum ) M: windows strerror ( errno -- str ) [ [ 1024 [ malloc &free ] keep ] dip - [ strerror_s drop ] 3keep 2drop + [ strerror_s drop ] keepdd utf8 alien>string ] with-destructors ; diff --git a/basis/logging/logging.factor b/basis/logging/logging.factor index 0ccc1b2536..5b670b6dc1 100644 --- a/basis/logging/logging.factor +++ b/basis/logging/logging.factor @@ -134,7 +134,7 @@ PRIVATE> '[ _ [ _ log-error @ ] recover ] ; : add-error-logging ( word level -- ) - [ [ input-logging-quot ] 2keep drop error-logging-quot ] + [ [ input-logging-quot ] keepd error-logging-quot ] (define-logging) ; SYNTAX: LOG: diff --git a/basis/math/combinatorics/combinatorics.factor b/basis/math/combinatorics/combinatorics.factor index c9f9a0e5da..d7ddc2ef6f 100644 --- a/basis/math/combinatorics/combinatorics.factor +++ b/basis/math/combinatorics/combinatorics.factor @@ -244,7 +244,7 @@ PRIVATE> [ drop pick [ combination ] [ 3drop f ] if ] 3bi ; inline : reduce-combinations ( ... seq k identity quot: ( ... prev elt -- ... next ) -- ... result ) - [ -rot ] dip each-combination ; inline + -rotd each-combination ; inline : all-subsets ( seq -- subsets ) dup length [0,b] [ all-combinations ] with map concat ; diff --git a/basis/math/functions/functions.factor b/basis/math/functions/functions.factor index c4b713ad16..026d033a2d 100644 --- a/basis/math/functions/functions.factor +++ b/basis/math/functions/functions.factor @@ -359,7 +359,7 @@ M: float truncate dup -52 shift 0x7ff bitand 0x3ff - ! check for floats without fractional part (>= 2^52) dup 52 < [ - [ drop ] 2dip + nipd dup 0 < [ ! the float is between -1.0 and 1.0, ! the result could be +/-0.0, but we will diff --git a/basis/math/matrices/elimination/elimination.factor b/basis/math/matrices/elimination/elimination.factor index d9117f023f..244cf2f42f 100644 --- a/basis/math/matrices/elimination/elimination.factor +++ b/basis/math/matrices/elimination/elimination.factor @@ -28,7 +28,7 @@ SYMBOL: matrix 0 swap nth-row [ zero? not ] skip ; : clear-scale ( col# pivot-row i-row -- n ) - [ over ] dip nth dup zero? [ + overd nth dup zero? [ 3drop 0 ] [ [ nth dup zero? ] dip swap [ diff --git a/basis/math/partial-dispatch/partial-dispatch.factor b/basis/math/partial-dispatch/partial-dispatch.factor index cc31dd6acd..fceee5a75d 100644 --- a/basis/math/partial-dispatch/partial-dispatch.factor +++ b/basis/math/partial-dispatch/partial-dispatch.factor @@ -143,7 +143,7 @@ SYMBOL: fast-math-ops : math-method* ( word left right -- quot ) 3dup math-op - [ [ 3drop ] dip 1quotation ] [ drop math-method ] if ; + [ 3nip 1quotation ] [ drop math-method ] if ; : math-both-known? ( word left right -- ? ) 3dup math-op diff --git a/basis/math/statistics/statistics.factor b/basis/math/statistics/statistics.factor index 79bbeb046f..32e0ce184e 100644 --- a/basis/math/statistics/statistics.factor +++ b/basis/math/statistics/statistics.factor @@ -269,7 +269,7 @@ ALIAS: std sample-std : pearson-r ( xy-pairs -- r ) r-stats (r) ; : least-squares ( xy-pairs -- alpha beta ) - r-stats [ 2dup ] 4 ndip + r-stats [ 2dup ] 4dip ! stack is x-mean y-mean x-mean y-mean x-seq y-seq x-std y-std [ (r) ] 2keep ! stack is mean(x) mean(y) r sx sy swap / * ! stack is mean(x) mean(y) beta diff --git a/basis/math/vectors/simd/intrinsics/intrinsics.factor b/basis/math/vectors/simd/intrinsics/intrinsics.factor index 4291a30aba..e2c9bb0448 100644 --- a/basis/math/vectors/simd/intrinsics/intrinsics.factor +++ b/basis/math/vectors/simd/intrinsics/intrinsics.factor @@ -268,16 +268,16 @@ PRIVATE> : (simd-vunpack-tail) ( a rep -- c ) [ byte>rep-array ] [ widen-vector-rep [ rep-length ] [ '[ _ >rep-array ] ] bi ] bi [ tail-slice ] dip call( a' -- c' ) underlying>> ; -: (simd-with) ( n rep -- v ) +: (simd-with) ( n rep -- v ) [ rep-length swap '[ _ ] ] [ ] bi replicate-as underlying>> ; : (simd-gather-2) ( m n rep -- v ) [ 2 set-firstn-unsafe ] keep underlying>> ; : (simd-gather-4) ( m n o p rep -- v ) [ 4 set-firstn-unsafe ] keep underlying>> ; : (simd-select) ( a n rep -- x ) swapd byte>rep-array nth-unsafe ; -: alien-vector ( c-ptr n rep -- value ) +: alien-vector ( c-ptr n rep -- value ) [ swap ] dip rep-size memory>byte-array ; -: set-alien-vector ( value c-ptr n rep -- ) +: set-alien-vector ( value c-ptr n rep -- ) [ swap swap ] dip rep-size memcpy ; "compiler.cfg.intrinsics.simd" require diff --git a/basis/opengl/shaders/shaders.factor b/basis/opengl/shaders/shaders.factor index 0c52028a31..a4a21880e7 100644 --- a/basis/opengl/shaders/shaders.factor +++ b/basis/opengl/shaders/shaders.factor @@ -66,7 +66,7 @@ PREDICATE: fragment-shader < gl-shader (fragment-shader?) ; : (gl-program) ( shaders quot: ( gl-program -- ) -- program ) glCreateProgram [ - rot dupd attach-shaders swap call + dup roll attach-shaders swap call ] [ glLinkProgram ] [ ] tri gl-error ; inline : ( shaders -- program ) diff --git a/basis/opengl/textures/textures.factor b/basis/opengl/textures/textures.factor index 0accf6f846..da08270c4a 100644 --- a/basis/opengl/textures/textures.factor +++ b/basis/opengl/textures/textures.factor @@ -290,7 +290,7 @@ TUPLE: single-texture < disposable image dim loc texture-coords texture display- : tex-sub-image ( image -- ) [ GL_TEXTURE_2D 0 0 0 ] dip [ dim>> first2 ] - [ image-format [ drop ] 2dip ] + [ image-format nipd ] [ bitmap>> ] tri glTexSubImage2D ; diff --git a/basis/peg/peg.factor b/basis/peg/peg.factor index f0545a17a3..54b081fdee 100644 --- a/basis/peg/peg.factor +++ b/basis/peg/peg.factor @@ -37,7 +37,7 @@ SYMBOL: error-stack : merge-errors ( -- ) error-stack get dup length 1 > [ - dup pop over pop swap (merge-errors) swap push + [ pop ] [ pop swap (merge-errors) ] [ ] tri push ] [ drop ] if ; @@ -144,7 +144,7 @@ TUPLE: peg-head rule-id involved-set eval-set ; [ [ setup-growth ] 2keep ] 2dip [ dup eval-rule ] dip swap dup pick stop-growth? [ - 5 ndrop + 5drop ] [ over update-m (grow-lr) @@ -347,7 +347,7 @@ TUPLE: satisfy-parser quot ; swap [ drop f ] [ - unclip-slice rot dupd call [ + unclip-slice dup roll call [ ] [ 2drop f diff --git a/basis/persistent/vectors/vectors.factor b/basis/persistent/vectors/vectors.factor index 862eed1aa9..368f7d6d3b 100644 --- a/basis/persistent/vectors/vectors.factor +++ b/basis/persistent/vectors/vectors.factor @@ -95,7 +95,7 @@ M: persistent-vector ppush ( val pvec -- pvec' ) : node-change-nth ( i node quot -- node' ) [ clone ] dip [ - [ clone ] dip [ change-nth ] 2keep drop + [ clone ] dip [ change-nth ] keepd ] curry change-children ; inline : (new-nth) ( val i node -- node' ) diff --git a/basis/regexp/regexp.factor b/basis/regexp/regexp.factor index ff383b272b..19d2d8710b 100644 --- a/basis/regexp/regexp.factor +++ b/basis/regexp/regexp.factor @@ -60,7 +60,7 @@ PRIVATE> :: next-match ( i string regexp quot: ( i string regexp -- j ) reverse? -- start end ? ) f f f i string reverse? search-range - [ [ 3drop ] dip string regexp quot reverse? (next-match) dup ] find 2drop ; inline + [ 3nip string regexp quot reverse? (next-match) dup ] find 2drop ; inline : do-next-match ( i string regexp -- start end ? ) dup next-match>> @@ -130,7 +130,7 @@ PRIVATE> ] [ 2drop f ] if ; : re-contains? ( string regexp -- ? ) - prepare-match-iterator do-next-match [ 2drop ] dip >boolean ; + prepare-match-iterator do-next-match 2nip >boolean ; : re-split ( string regexp -- seq ) [ ] (re-split) ; diff --git a/basis/sequences/generalizations/generalizations-tests.factor b/basis/sequences/generalizations/generalizations-tests.factor index f16b1b4e86..a0e3b02b75 100644 --- a/basis/sequences/generalizations/generalizations-tests.factor +++ b/basis/sequences/generalizations/generalizations-tests.factor @@ -36,12 +36,10 @@ IN: sequences.generalizations.tests [ 4 nappend print ] 4 0 mnmap ; : nproduce-as-test ( n -- a b ) [ dup zero? not ] - [ [ 2 - ] [ ] [ 1 - ] tri ] { } B{ } 2 nproduce-as - [ drop ] 2dip ; + [ [ 2 - ] [ ] [ 1 - ] tri ] { } B{ } 2 nproduce-as nipd ; : nproduce-test ( n -- a b ) [ dup zero? not ] - [ [ 2 - ] [ ] [ 1 - ] tri ] 2 nproduce - [ drop ] 2dip ; + [ [ 2 - ] [ ] [ 1 - ] tri ] 2 nproduce nipd ; { "A1a! B2b@ diff --git a/basis/sequences/generalizations/generalizations.factor b/basis/sequences/generalizations/generalizations.factor index f798106f7c..ef83ab7e0d 100644 --- a/basis/sequences/generalizations/generalizations.factor +++ b/basis/sequences/generalizations/generalizations.factor @@ -117,7 +117,7 @@ MACRO: (ncollect) ( n -- quot ) [ { } swap dupn ] keep nproduce-as ; inline MACRO: nmap-reduce ( map-quot reduce-quot n -- quot ) - -rot dupd compose [ over ] dip over '[ + -rot dupd compose overd over '[ [ [ first ] _ napply @ 1 ] _ nkeep _ _ (neach) (each-integer) ] ; diff --git a/basis/sequences/merged/merged.factor b/basis/sequences/merged/merged.factor index dbfc90d555..233683c47a 100644 --- a/basis/sequences/merged/merged.factor +++ b/basis/sequences/merged/merged.factor @@ -14,10 +14,10 @@ C: merged [ ] keep first like ; : 2merge ( seq1 seq2 -- seq ) - [ <2merged> ] 2keep drop like ; + [ <2merged> ] keepd like ; : 3merge ( seq1 seq2 seq3 -- seq ) - [ <3merged> ] 3keep 2drop like ; + [ <3merged> ] keepdd like ; M: merged length seqs>> [ [ length ] [ min ] map-reduce ] [ length ] bi * ; inline diff --git a/basis/sequences/parser/parser.factor b/basis/sequences/parser/parser.factor index 6f139cbeeb..0babf4b9c8 100644 --- a/basis/sequences/parser/parser.factor +++ b/basis/sequences/parser/parser.factor @@ -62,7 +62,7 @@ TUPLE: sequence-parser sequence n ; : ( from to seq -- slice/f ) 3dup { [ 2drop 0 < ] - [ [ drop ] 2dip length > ] + [ nipd length > ] [ drop > ] } 3|| [ 3drop f ] [ ] if ; inline diff --git a/basis/sequences/unrolled/unrolled.factor b/basis/sequences/unrolled/unrolled.factor index 94468e69e6..543aed2814 100644 --- a/basis/sequences/unrolled/unrolled.factor +++ b/basis/sequences/unrolled/unrolled.factor @@ -25,7 +25,7 @@ PRIVATE> (unrolled-collect) unrolled-each-integer ; inline : unrolled-map-integers ( n quot: ( n -- value ) exemplar -- newseq ) - [ over ] dip [ [ unrolled-collect ] keep ] new-like ; inline + overd [ [ unrolled-collect ] keep ] new-like ; inline ERROR: unrolled-bounds-error seq unroll-length ; @@ -70,7 +70,7 @@ ERROR: unrolled-2bounds-error pick unrolled-map-as-unsafe ; inline : unrolled-2map-unsafe ( xseq yseq len quot: ( x y -- newx ) -- newseq ) - 4 npick unrolled-2map-as-unsafe ; inline + reach unrolled-2map-as-unsafe ; inline PRIVATE> @@ -93,7 +93,7 @@ PRIVATE> pick unrolled-map-as ; inline : unrolled-2map ( xseq yseq len quot: ( x y -- newx ) -- newseq ) - 4 npick unrolled-2map-as ; inline + reach unrolled-2map-as ; inline : unrolled-map-index ( seq len quot: ( x i -- newx ) -- newseq ) [ dup length ] 2dip unrolled-2map ; inline diff --git a/basis/sequences/windowed/windowed.factor b/basis/sequences/windowed/windowed.factor index 19458157d6..df2b05b58c 100644 --- a/basis/sequences/windowed/windowed.factor +++ b/basis/sequences/windowed/windowed.factor @@ -22,7 +22,7 @@ M: windowed-sequence length [ drop 0 ] [ length ] bi clamp ; inline : in-bounds ( a b sequence -- a' b' sequence ) - [ nip in-bound ] [ [ nip ] dip in-bound ] [ 2nip ] 3tri ; + [ nip in-bound ] [ nipd in-bound ] [ 2nip ] 3tri ; :: rolling-map ( ... seq n quot: ( ... slice -- ... elt ) -- ... newseq ) seq length [ diff --git a/basis/shuffle/shuffle-docs.factor b/basis/shuffle/shuffle-docs.factor deleted file mode 100644 index 363727a6c5..0000000000 --- a/basis/shuffle/shuffle-docs.factor +++ /dev/null @@ -1,7 +0,0 @@ -USING: help.markup help.syntax ; -IN: shuffle - -HELP: spin $complex-shuffle ; -HELP: roll $complex-shuffle ; -HELP: -roll $complex-shuffle ; -HELP: tuck $complex-shuffle ; diff --git a/basis/shuffle/shuffle-tests.factor b/basis/shuffle/shuffle-tests.factor index 4d176f7b32..b9eee02ce0 100644 --- a/basis/shuffle/shuffle-tests.factor +++ b/basis/shuffle/shuffle-tests.factor @@ -3,6 +3,3 @@ USING: shuffle tools.test ; { 1 2 3 4 } [ 3 4 1 2 2swap ] unit-test { 4 2 3 } [ 1 2 3 4 shuffle( a b c d -- d b c ) ] unit-test - -{ 2 3 4 1 } [ 1 2 3 4 roll ] unit-test -{ 1 2 3 4 } [ 2 3 4 1 -roll ] unit-test diff --git a/basis/shuffle/shuffle.factor b/basis/shuffle/shuffle.factor index 03d3caed8b..bc78fd6dc8 100644 --- a/basis/shuffle/shuffle.factor +++ b/basis/shuffle/shuffle.factor @@ -14,12 +14,6 @@ MACRO: shuffle-effect ( effect -- quot ) SYNTAX: shuffle( ")" parse-effect suffix! \ shuffle-effect suffix! ; -: tuck ( x y -- y x y ) swap over ; inline deprecated - : spin ( x y z -- z y x ) swap rot ; inline deprecated -: roll ( x y z t -- y z t x ) [ rot ] dip swap ; inline deprecated - -: -roll ( x y z t -- t x y z ) swap [ -rot ] dip ; inline deprecated - : 2swap ( x y z t -- z t x y ) 2 2 mnswap ; inline diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor index d56e2ee785..40486c679a 100644 --- a/basis/stack-checker/known-words/known-words.factor +++ b/basis/stack-checker/known-words/known-words.factor @@ -61,23 +61,34 @@ IN: stack-checker.known-words } cond ; { - { drop ( x -- ) } - { 2drop ( x y -- ) } - { 3drop ( x y z -- ) } - { 4drop ( w x y z -- ) } - { dup ( x -- x x ) } - { 2dup ( x y -- x y x y ) } - { 3dup ( x y z -- x y z x y z ) } - { 4dup ( w x y z -- w x y z w x y z ) } - { rot ( x y z -- y z x ) } - { -rot ( x y z -- z x y ) } - { dupd ( x y -- x x y ) } - { swapd ( x y z -- y x z ) } - { nip ( x y -- y ) } - { 2nip ( x y z -- z ) } - { over ( x y -- x y x ) } - { pick ( x y z -- x y z x ) } - { swap ( x y -- y x ) } + { drop ( x -- ) } + { 2drop ( x y -- ) } + { 3drop ( x y z -- ) } + { 4drop ( w x y z -- ) } + { dup ( x -- x x ) } + { 2dup ( x y -- x y x y ) } + { 3dup ( x y z -- x y z x y z ) } + { 4dup ( w x y z -- w x y z w x y z ) } + { rot ( x y z -- y z x ) } + { -rot ( x y z -- z x y ) } + { roll ( w x y z -- x y z w ) } + { -roll ( w x y z -- z w x y ) } + { reach ( w x y z -- w x y z w ) } + { dupd ( x y -- x x y ) } + { swapd ( x y z -- y x z ) } + { nip ( x y -- y ) } + { 2nip ( x y z -- z ) } + { 3nip ( w x y z -- z ) } + { 4nip ( v w x y z -- z ) } + { nipd ( x y z -- y z ) } + { 2nipd ( w x y z -- y z ) } + { 3nipd ( v w x y z -- y z ) } + { over ( x y -- x y x ) } + { overd ( x y z -- x y x z ) } + { pick ( x y z -- x y z x ) } + { pickd ( w x y z -- w x y w z ) } + { swap ( x y -- y x ) } + { tuck ( x y -- y x y ) } } [ "shuffle" set-word-prop ] assoc-each : check-declaration ( declaration -- declaration ) diff --git a/basis/stack-checker/stack-checker-tests.factor b/basis/stack-checker/stack-checker-tests.factor index 93a3957dc3..267245daed 100644 --- a/basis/stack-checker/stack-checker-tests.factor +++ b/basis/stack-checker/stack-checker-tests.factor @@ -453,7 +453,7 @@ DEFER: eee' ! ensure that polymorphic checking works on recursive combinators : (recursive-reduce) ( identity i seq quot: ( prev elt -- next ) n -- result ) - [ pick ] dip swap over < [ + pickd tuck < [ [ [ [ nth-unsafe ] dip call ] 3keep [ 1 + ] 2dip ] dip (recursive-reduce) ] [ 4drop ] if ; inline recursive diff --git a/basis/tools/deploy/backend/backend.factor b/basis/tools/deploy/backend/backend.factor index ec86089dbe..3b424823d5 100644 --- a/basis/tools/deploy/backend/backend.factor +++ b/basis/tools/deploy/backend/backend.factor @@ -20,7 +20,7 @@ ERROR: can't-deploy-library-file library ; : copy-library ( dir library -- ) dup find-library-file - [ swap over file-name append-path copy-file ] + [ tuck file-name append-path copy-file ] [ can't-deploy-library-file ] ?if ; : copy-libraries ( manifest name dir -- ) diff --git a/basis/ui/backend/windows/windows.factor b/basis/ui/backend/windows/windows.factor index 39e4ce755a..2b7751d932 100755 --- a/basis/ui/backend/windows/windows.factor +++ b/basis/ui/backend/windows/windows.factor @@ -458,7 +458,7 @@ SYMBOL: nc-buttons : handle-wm-buttonup ( hWnd uMsg wParam lParam -- ) mouse-captured get [ release-capture ] when pick message>button drop dup nc-buttons get member? [ - nc-buttons get remove! drop 4drop + nc-buttons get remove! 5drop ] [ drop prepare-mouse send-button-up ] if ; diff --git a/basis/unicode/normalize/normalize.factor b/basis/unicode/normalize/normalize.factor index 5c9065dc91..791d71e121 100644 --- a/basis/unicode/normalize/normalize.factor +++ b/basis/unicode/normalize/normalize.factor @@ -137,7 +137,7 @@ DEFER: compose-iter : try-noncombining ( state char -- state ) [ drop ] [ [ char>> ] dip combine-chars ] 2bi - [ >>char to f >>last-class compose-iter ] when* ; inline + [ >>char to f >>last-class compose-iter ] when* ; inline recursive : compose-iter ( state -- state ) dup current [ diff --git a/basis/windows/directx/dinput/constants/constants.factor b/basis/windows/directx/dinput/constants/constants.factor index 4c4ddcde7a..18a0e41750 100755 --- a/basis/windows/directx/dinput/constants/constants.factor +++ b/basis/windows/directx/dinput/constants/constants.factor @@ -71,7 +71,7 @@ M: array array-base-type first ; >> MACRO: ( dwFlags dwDataSize struct rgodf-array -- alien ) - [ DIDATAFORMAT heap-size DIOBJECTDATAFORMAT heap-size ] 4 ndip + [ DIDATAFORMAT heap-size DIOBJECTDATAFORMAT heap-size ] 4dip [ nip length ] [ make-DIOBJECTDATAFORMAT-array-quot ] 2bi '[ _ _ _ _ _ @ DIDATAFORMAT ] ; diff --git a/basis/windows/iphlpapi/iphlpapi.factor b/basis/windows/iphlpapi/iphlpapi.factor index e3f2da7b18..8f910e0d26 100644 --- a/basis/windows/iphlpapi/iphlpapi.factor +++ b/basis/windows/iphlpapi/iphlpapi.factor @@ -387,7 +387,7 @@ FUNCTION: DWORD GetNetworkParams ( PFIXED_INFO pFixedInfo, PULONG pOutBufLen ) : get-fixed-info ( -- FIXED_INFO ) FIXED_INFO dup byte-length ulong - [ GetNetworkParams n>win32-error-check ] 2keep drop ; + [ GetNetworkParams n>win32-error-check ] keepd ; : dns-server-ips ( -- sequence ) get-fixed-info DnsServerList>> [ diff --git a/basis/xml/tests/xmltest/canonxml.html b/basis/xml/tests/xmltest/canonxml.html index 2ba0edf6c6..45a6f803b8 100644 --- a/basis/xml/tests/xmltest/canonxml.html +++ b/basis/xml/tests/xmltest/canonxml.html @@ -1,44 +1,44 @@ - -Canonical XML - -

Canonical XML

-

-This document defines a subset of XML called canonical XML. -The intended use of canonical XML is in testing XML processors, -as a representation of the result of parsing an XML document. -

-Every well-formed XML document has a unique structurally equivalent -canonical XML document. Two structurally equivalent XML -documents have a byte-for-byte identical canonical XML document. -Canonicalizing an XML document requires only information that an XML -processor is required to make available to an application. -

-A canonical XML document conforms to the following grammar: -

-CanonXML    ::= Pi* element Pi*
-element     ::= Stag (Datachar | Pi | element)* Etag
-Stag        ::= '<'  Name Atts '>'
-Etag        ::= '</' Name '>'
-Pi          ::= '<?' Name ' ' (((Char - S) Char*)? - (Char* '?>' Char*)) '?>'
-Atts        ::= (' ' Name '=' '"' Datachar* '"')*
-Datachar    ::= '&amp;' | '&lt;' | '&gt;' | '&quot;'
-                 | '&#9;'| '&#10;'| '&#13;'
-                 | (Char - ('&' | '<' | '>' | '"' | #x9 | #xA | #xD))
-Name        ::= (see XML spec)
-Char        ::= (see XML spec)
-S           ::= (see XML spec)
-
-

-Attributes are in lexicographical order (in Unicode bit order). -

-A canonical XML document is encoded in UTF-8. -

-Ignorable white space is considered significant and is treated equivalently -to data. -

-

-James Clark -
- - + +Canonical XML + +

Canonical XML

+

+This document defines a subset of XML called canonical XML. +The intended use of canonical XML is in testing XML processors, +as a representation of the result of parsing an XML document. +

+Every well-formed XML document has a unique structurally equivalent +canonical XML document. Two structurally equivalent XML +documents have a byte-for-byte identical canonical XML document. +Canonicalizing an XML document requires only information that an XML +processor is required to make available to an application. +

+A canonical XML document conforms to the following grammar: +

+CanonXML    ::= Pi* element Pi*
+element     ::= Stag (Datachar | Pi | element)* Etag
+Stag        ::= '<'  Name Atts '>'
+Etag        ::= '</' Name '>'
+Pi          ::= '<?' Name ' ' (((Char - S) Char*)? - (Char* '?>' Char*)) '?>'
+Atts        ::= (' ' Name '=' '"' Datachar* '"')*
+Datachar    ::= '&amp;' | '&lt;' | '&gt;' | '&quot;'
+                 | '&#9;'| '&#10;'| '&#13;'
+                 | (Char - ('&' | '<' | '>' | '"' | #x9 | #xA | #xD))
+Name        ::= (see XML spec)
+Char        ::= (see XML spec)
+S           ::= (see XML spec)
+
+

+Attributes are in lexicographical order (in Unicode bit order). +

+A canonical XML document is encoded in UTF-8. +

+Ignorable white space is considered significant and is treated equivalently +to data. +

+

+James Clark +
+ + \ No newline at end of file diff --git a/basis/xml/tests/xmltest/readme.html b/basis/xml/tests/xmltest/readme.html index fc7310c68e..9f976ec774 100644 --- a/basis/xml/tests/xmltest/readme.html +++ b/basis/xml/tests/xmltest/readme.html @@ -1,60 +1,60 @@ - -XML Test Cases - -

XML Test Cases version 1998-11-18

-

-Copyright (C) 1998 James Clark. All rights reserved. Permission is -granted to copy and modify this collection in any way for internal use -within a company or organization. Permission is granted to -redistribute the file xmltest.zip containing this -collection to third parties provided that no modifications of any kind -are made to this file. Note that permission to distribute the -collection in any other form is not granted. -

-The collection is structured into three directories: -

-
not-wf -
this contains cases that are not well-formed XML documents -
valid -
this contains cases that are valid XML documents -
invalid -
this contains cases that are well-formed XML documents -but are not valid XML documents -
-

-The not-wf and valid directories each have -three subdirectories: -

-
-sa -
-this contains cases that are standalone (as defined in XML) and do not -have references to external general entities -
-ext-sa -
-this contains case that are standalone and have references to external -general entities -
-not-sa -
-this contains cases that are not standalone -
-

-In each directory, files with a .xml extension are the -XML document test cases, and files with a .ent extension -are external entities referenced by the test cases. -

-Within the valid directory, each of these three -subdirectories has an out subdirectory which contains an -equivalent canonical XML document for each -of the cases. -

-

-Bug reports and contributions of new test cases are welcome. -

-

-James Clark -
- - + +XML Test Cases + +

XML Test Cases version 1998-11-18

+

+Copyright (C) 1998 James Clark. All rights reserved. Permission is +granted to copy and modify this collection in any way for internal use +within a company or organization. Permission is granted to +redistribute the file xmltest.zip containing this +collection to third parties provided that no modifications of any kind +are made to this file. Note that permission to distribute the +collection in any other form is not granted. +

+The collection is structured into three directories: +

+
not-wf +
this contains cases that are not well-formed XML documents +
valid +
this contains cases that are valid XML documents +
invalid +
this contains cases that are well-formed XML documents +but are not valid XML documents +
+

+The not-wf and valid directories each have +three subdirectories: +

+
+sa +
+this contains cases that are standalone (as defined in XML) and do not +have references to external general entities +
+ext-sa +
+this contains case that are standalone and have references to external +general entities +
+not-sa +
+this contains cases that are not standalone +
+

+In each directory, files with a .xml extension are the +XML document test cases, and files with a .ent extension +are external entities referenced by the test cases. +

+Within the valid directory, each of these three +subdirectories has an out subdirectory which contains an +equivalent canonical XML document for each +of the cases. +

+

+Bug reports and contributions of new test cases are welcome. +

+

+James Clark +
+ + diff --git a/basis/xml/tokenize/tokenize.factor b/basis/xml/tokenize/tokenize.factor index 0d04064022..8d795851c9 100644 --- a/basis/xml/tokenize/tokenize.factor +++ b/basis/xml/tokenize/tokenize.factor @@ -87,7 +87,7 @@ HINTS: next* { spot } ; [ blank? not ] skip-until ; : next-matching ( pos ch str -- pos' ) - [ over ] dip nth eq? [ 1 + ] [ drop 0 ] if ; inline + overd nth eq? [ 1 + ] [ drop 0 ] if ; inline : string-matcher ( str -- quot: ( pos char -- pos ? ) ) dup length 1 - '[ _ next-matching dup _ > ] ; inline diff --git a/basis/xmode/catalog/catalog.factor b/basis/xmode/catalog/catalog.factor index 89bc0a6e93..a96389d30a 100644 --- a/basis/xmode/catalog/catalog.factor +++ b/basis/xmode/catalog/catalog.factor @@ -117,7 +117,7 @@ DEFER: finalize-rule-set [ file-name ] dip modes [ nip [ 2dup ] dip suitable-mode? ] assoc-find - 2drop [ 2drop ] dip ; + 2drop 2nip ; : find-mode ( file-name first-line -- mode ) ?find-mode "text" or ; inline diff --git a/core/alien/strings/strings.factor b/core/alien/strings/strings.factor index 74fdfb5637..2a4b3d9ebc 100644 --- a/core/alien/strings/strings.factor +++ b/core/alien/strings/strings.factor @@ -38,7 +38,7 @@ M: c-ptr string>alien drop ; drop [ length ] keep over [ 1 + (byte-array) [ [ - [ [ string-nth-fast ] 2keep drop ] + [ [ string-nth-fast ] keepd ] [ set-nth-unsafe ] bi* ] 2curry each-integer ] keep diff --git a/core/assocs/assocs.factor b/core/assocs/assocs.factor index 40fb12ac81..9f4a417042 100644 --- a/core/assocs/assocs.factor +++ b/core/assocs/assocs.factor @@ -37,7 +37,7 @@ M: assoc assoc-like drop ; inline 3drop f ] [ 3dup nth-unsafe at* - [ [ 3drop ] dip ] [ drop [ 1 - ] dip (assoc-stack) ] if + [ 3nip ] [ drop [ 1 - ] dip (assoc-stack) ] if ] if ; inline recursive : search-alist ( key alist -- pair/f i/f ) @@ -156,7 +156,7 @@ M: assoc values [ nip ] { } assoc>map ; over [ set-at ] with-assoc assoc-each ; : assoc-union-as ( assoc1 assoc2 exemplar -- union ) - [ [ [ assoc-size ] bi@ + ] dip new-assoc ] 3keep drop + [ [ [ assoc-size ] bi@ + ] dip new-assoc ] 2keepd [ assoc-union! ] bi@ ; : assoc-union ( assoc1 assoc2 -- union ) diff --git a/core/classes/tuple/parser/parser.factor b/core/classes/tuple/parser/parser.factor index 1ca47ee2ef..12667ffb5d 100644 --- a/core/classes/tuple/parser/parser.factor +++ b/core/classes/tuple/parser/parser.factor @@ -97,7 +97,7 @@ M: tuple-class boa>object swap slots>tuple ; : check-slot-exists ( class initials slot-spec/f index/f name -- class initials slot-spec index ) - over [ drop ] [ nip nip nip bad-slot-name ] if ; + over [ drop ] [ 3nip bad-slot-name ] if ; : slot-named-checked ( class initials name slots -- class initials slot-spec ) over [ slot-named* ] dip check-slot-exists drop ; diff --git a/core/classes/tuple/tuple.factor b/core/classes/tuple/tuple.factor index e260e3530e..029c800939 100644 --- a/core/classes/tuple/tuple.factor +++ b/core/classes/tuple/tuple.factor @@ -208,7 +208,7 @@ M: object final-class? drop f ; pick [ [ [ swap nth dup ] dip instance? ] dip swap [ drop ] [ nip ] if - ] [ [ 3drop ] dip ] if ; + ] [ 3nip ] if ; : apply-slot-permutation ( old-values triples -- new-values ) [ first3 update-slot ] with map ; diff --git a/core/effects/effects.factor b/core/effects/effects.factor index 010d4d4d97..ffdc4ead39 100644 --- a/core/effects/effects.factor +++ b/core/effects/effects.factor @@ -21,7 +21,7 @@ TUPLE: effect f f effect boa ; inline : ( in-var in out-var out -- effect ) - swap [ rot ] dip [ ?terminated ] 2dip effect boa ; + swap rotd [ ?terminated ] 2dip effect boa ; : effect-height ( effect -- n ) [ out>> length ] [ in>> length ] bi - ; inline diff --git a/core/effects/parser/parser.factor b/core/effects/parser/parser.factor index 46629023ed..75fdf63d27 100644 --- a/core/effects/parser/parser.factor +++ b/core/effects/parser/parser.factor @@ -45,7 +45,7 @@ PRIVATE> { [ effect-closer? ] [ stack-effect-omits-dashes ] } { [ row-variable? ] [ parse-effect-var t ] } [ - [ drop ] 2dip standalone-type? + nipd standalone-type? [ parse-standalone-type ] [ parse-effect-value ] if , t ] } cond ; diff --git a/core/generic/generic.factor b/core/generic/generic.factor index 65fbb300f4..7571eb66b9 100644 --- a/core/generic/generic.factor +++ b/core/generic/generic.factor @@ -191,7 +191,7 @@ GENERIC#: check-combination-effect 1 ( combination effect -- ) M: object check-combination-effect 2drop ; : define-generic ( word combination effect -- ) - [ [ check-combination-effect ] keep swap set-stack-effect ] + [ [ check-combination-effect ] keep set-stack-effect ] [ drop 2dup [ "combination" word-prop ] dip = [ 2drop ] [ diff --git a/core/growable/growable.factor b/core/growable/growable.factor index 09189991f7..2f7554a762 100644 --- a/core/growable/growable.factor +++ b/core/growable/growable.factor @@ -20,7 +20,7 @@ M: growable set-nth-unsafe underlying>> set-nth-unsafe ; inline [ set-nth-unsafe ] [ [ 1 fixnum+fast ] dip length<< ] 2bi ; inline : push-all-unsafe ( from to src dst -- ) - [ over - swap ] 2dip [ pick ] dip [ length integer>fixnum ] keep + [ over - swap ] 2dip pickd [ length integer>fixnum ] keep [ [ fixnum+fast ] dip length<< ] 2keep (copy) drop ; inline PRIVATE> diff --git a/core/hash-sets/hash-sets.factor b/core/hash-sets/hash-sets.factor index 1a7cbad43f..aec8aa77f1 100644 --- a/core/hash-sets/hash-sets.factor +++ b/core/hash-sets/hash-sets.factor @@ -49,7 +49,7 @@ TUPLE: hash-set [ pick or [ probe ] dip (new-key@) ] if ] [ - [ [ pick ] dip = ] 2dip rot + [ pickd = ] 2dip rot [ nip [ drop ] 3dip f ] [ [ probe ] dip (new-key@) ] if @@ -125,7 +125,7 @@ M: hash-set ?adjoin M: hash-set members [ array>> 0 swap ] [ cardinality f ] bi [ - [ [ over ] dip set-nth-unsafe 1 + ] curry each-member + [ overd set-nth-unsafe 1 + ] curry each-member ] keep nip ; M: hash-set clone diff --git a/core/hashtables/hashtables.factor b/core/hashtables/hashtables.factor index d7763428d7..9cda95da6a 100644 --- a/core/hashtables/hashtables.factor +++ b/core/hashtables/hashtables.factor @@ -73,7 +73,7 @@ TUPLE: hashtable [ pick or [ probe ] dip (new-key@) ] if ] [ - [ [ pick ] dip = ] 2dip rot + [ pickd = ] 2dip rot [ nip [ drop ] 3dip f ] [ [ probe ] dip (new-key@) ] if @@ -154,7 +154,7 @@ M: hashtable set-at : collect-pairs ( hash quot: ( key value -- elt ) -- seq ) [ [ array>> 0 swap ] [ assoc-size f ] bi ] dip swap [ - [ [ over ] dip set-nth-unsafe 1 + ] curry compose each-pair + [ overd set-nth-unsafe 1 + ] curry compose each-pair ] keep nip ; inline PRIVATE> diff --git a/core/io/encodings/encodings.factor b/core/io/encodings/encodings.factor index fc1d24375e..5fef2f1be6 100644 --- a/core/io/encodings/encodings.factor +++ b/core/io/encodings/encodings.factor @@ -44,7 +44,7 @@ CONSTANT: replacement-char 0xfffd { string } declare ! aux>> must be f [ length ] keep over (byte-array) [ [ - [ [ string-nth-fast ] 2keep drop ] + [ [ string-nth-fast ] keepd ] [ set-nth-unsafe ] bi* ] 2curry each-integer ] keep ; inline @@ -53,7 +53,7 @@ CONSTANT: replacement-char 0xfffd { byte-array } declare [ length ] keep over 0 [ [ - [ [ nth-unsafe ] 2keep drop ] + [ [ nth-unsafe ] keepd ] [ pick 127 <= [ set-string-nth-fast ] @@ -119,17 +119,14 @@ M: decoder stream-read1 ( decoder -- ch ) : (store-read) ( buf stream encoding n c i -- buf stream encoding n ) [ rot [ set-nth-unsafe ] keep ] 2curry 3dip ; inline -: (finish-read) ( buf stream encoding n i -- i ) - 2nip 2nip ; inline - : (read-next) ( stream encoding n i -- stream encoding n i c ) [ 2dup decode-char ] 2dip rot ; inline : (read-rest) ( buf stream encoding n i -- count ) - 2dup = [ (finish-read) ] [ + 2dup = [ 4nip ] [ (read-next) [ swap [ (store-read) ] [ 1 + ] bi (read-rest) - ] [ (finish-read) ] if* + ] [ 4nip ] if* ] if ; inline recursive M: decoder stream-read-unsafe @@ -167,11 +164,11 @@ M: decoder stream-read-until dup CHAR: \n = [ 2drop stream-read-until ] [ - [ 2drop ] 2dip + 2nipd ] if ] [ first-unsafe CHAR: \n = [ [ rest ] dip ] when - [ 2drop ] 2dip + 2nipd ] if-empty ] [ >decoder< decode-until diff --git a/core/io/encodings/utf16/utf16.factor b/core/io/encodings/utf16/utf16.factor index bce99cbcca..112667575b 100644 --- a/core/io/encodings/utf16/utf16.factor +++ b/core/io/encodings/utf16/utf16.factor @@ -101,13 +101,13 @@ M: utf16le encode-char ( char stream encoding -- ) drop char>utf16le ; : ascii-char>utf16-byte-array ( off n byte-array string -- ) - [ over ] dip string-nth-fast -rot + overd string-nth-fast -rot [ 2 fixnum*fast rot fixnum+fast ] dip set-nth-unsafe ; inline : ascii-string>utf16-byte-array ( off string -- byte-array ) [ length >fixnum [ ] [ 2 fixnum*fast ] bi ] keep - [ [ ascii-char>utf16-byte-array ] 2curry with each ] 2keep drop ; inline + [ [ ascii-char>utf16-byte-array ] 2curry with each ] keepd ; inline : ascii-string>utf16le ( string stream -- ) [ 0 swap ascii-string>utf16-byte-array ] dip stream-write ; inline diff --git a/core/io/io.factor b/core/io/io.factor index fc804f0680..d1e345a2a8 100644 --- a/core/io/io.factor +++ b/core/io/io.factor @@ -118,11 +118,11 @@ SYMBOL: error-stream stream-exemplar new-sequence ; inline : resize-if-necessary ( wanted-n got-n seq -- seq' ) - 2over = [ [ 2drop ] dip ] [ resize nip ] if ; inline + 2over = [ 2nip ] [ resize nip ] if ; inline : (read-into-new) ( n stream quot -- seq/f ) [ dup ] 2dip - [ 2dup (new-sequence-for-stream) swap ] dip curry keep + [ 2dup (new-sequence-for-stream) swap ] dip keepd over 0 = [ 3drop f ] [ resize-if-necessary ] if ; inline : (read-into) ( buf stream quot -- buf-slice/f ) @@ -173,7 +173,7 @@ CONSTANT: each-block-size 65536 : (each-stream-block-slice) ( ... stream quot: ( ... block-slice -- ... ) block-size -- ... ) [ [ drop ] prepose swap ] dip - [ swap (new-sequence-for-stream) ] curry keep + [ swap (new-sequence-for-stream) ] keepd [ stream-read-partial-into ] 2curry each-morsel drop ; inline : each-stream-block-slice ( ... stream quot: ( ... block-slice -- ... ) -- ... ) @@ -194,7 +194,7 @@ CONSTANT: each-block-size 65536 : (stream-contents-by-length) ( stream len -- seq ) dup rot [ (new-sequence-for-stream) ] - [ [ stream-read-unsafe ] curry keep resize ] bi ; inline + [ [ stream-read-unsafe ] keepd resize ] bi ; inline : (stream-contents-by-block) ( stream -- seq ) [ [ ] collector [ each-stream-block ] dip { } like ] @@ -225,11 +225,11 @@ CONSTANT: each-block-size 65536 swap ; inline : with-byte-writer ( encoding quot -- byte-array ) - [ ] dip [ with-output-stream* ] 2keep drop + [ ] dip [ with-output-stream* ] keepd dup encoder? [ stream>> ] when >byte-array ; inline TUPLE: byte-reader { underlying byte-array read-only } { i array-capacity } ; diff --git a/core/io/streams/c/c.factor b/core/io/streams/c/c.factor index 8dc14ef55f..8d1d3207c5 100644 --- a/core/io/streams/c/c.factor +++ b/core/io/streams/c/c.factor @@ -53,9 +53,9 @@ M: c-reader stream-read1 : read-until-loop ( handle seps accum -- accum ch ) pick fgetc dup [ pick dupd member-eq? - [ [ 2drop ] 2dip ] [ suffix! read-until-loop ] if + [ 2nipd ] [ suffix! read-until-loop ] if ] [ - [ 2drop ] 2dip + 2nipd ] if ; inline recursive M: c-reader stream-read-until diff --git a/core/io/streams/sequence/sequence.factor b/core/io/streams/sequence/sequence.factor index 8760299b33..5a6a1618ca 100644 --- a/core/io/streams/sequence/sequence.factor +++ b/core/io/streams/sequence/sequence.factor @@ -41,7 +41,7 @@ ERROR: not-a-string obj ; [ integer>fixnum ] [ dup slice? [ [ seq>> ] [ from>> ] bi ] [ 0 ] if ] [ - swap over stream-element-type +byte+ eq? + tuck stream-element-type +byte+ eq? [ check-byte-array sequence-copy-unsafe ] [ check-string sequence-copy-unsafe ] if ] tri* ; inline diff --git a/core/kernel/kernel-docs.factor b/core/kernel/kernel-docs.factor index a484139bc0..3f290bdea7 100644 --- a/core/kernel/kernel-docs.factor +++ b/core/kernel/kernel-docs.factor @@ -40,6 +40,9 @@ HELP: 2over $shuffle ; HELP: pick $shuffle ; HELP: swap $shuffle ; +HELP: roll $complex-shuffle ; +HELP: -roll $complex-shuffle ; +HELP: tuck $complex-shuffle ; HELP: rot $complex-shuffle ; HELP: -rot $complex-shuffle ; HELP: dupd $complex-shuffle ; diff --git a/core/kernel/kernel-tests.factor b/core/kernel/kernel-tests.factor index 23f12b419d..a1942a4de8 100644 --- a/core/kernel/kernel-tests.factor +++ b/core/kernel/kernel-tests.factor @@ -132,7 +132,7 @@ IN: kernel.tests ! Regression : (loop) ( a b c d -- ) - [ pick ] dip swap [ pick ] dip swap + pickd swap pickd swap < [ [ 1 + ] 3dip (loop) ] [ 4drop ] if ; inline recursive : loop ( obj -- ) @@ -201,3 +201,6 @@ IN: kernel.tests { 1 2 3 1 2 3 } [ 1 2 3 3dup ] unit-test { 1 2 3 4 1 2 3 4 } [ 1 2 3 4 4dup ] unit-test + +{ 2 3 4 1 } [ 1 2 3 4 roll ] unit-test +{ 1 2 3 4 } [ 2 3 4 1 -roll ] unit-test diff --git a/core/kernel/kernel.factor b/core/kernel/kernel.factor index cc2d132fda..cf1cf2a192 100644 --- a/core/kernel/kernel.factor +++ b/core/kernel/kernel.factor @@ -116,6 +116,39 @@ DEFER: if : 4dip ( w x y z quot -- w x y z ) swap [ 3dip ] dip ; inline +! Misfits +: tuck ( x y -- y x y ) dup -rot ; inline + +: spin ( x y z -- z y x ) -rot swap ; inline + +: rotd ( w x y z -- x y w z ) [ rot ] dip ; inline + +: -rotd ( w x y z -- w z x y ) [ -rot ] dip ; inline + +: roll ( w x y z -- x y z w ) rotd swap ; inline + +: -roll ( w x y z -- z w x y ) swap -rotd ; inline + +: nipd ( x y z -- y z ) [ nip ] dip ; inline + +: overd ( x y z -- x y x z ) [ over ] dip ; inline + +: pickd ( w x y z -- w x y w z ) [ pick ] dip ; inline + +: 2nipd ( w x y z -- y z ) [ 2drop ] 2dip ; inline + +: 3nipd ( v w x y z -- y z ) [ 3drop ] 2dip ; inline + +: 3nip ( w x y z -- z ) 2nip nip ; inline + +: 4nip ( v w x y z -- z ) 2nip 2nip ; inline + +: 5nip ( u v w x y z -- z ) 3nip 2nip ; inline + +: 5drop ( v w x y z -- ) 4drop drop ; inline + +: reach ( w x y z -- w x y z w ) [ pick ] dip swap ; inline + ! Keepers : keep ( ..a x quot: ( ..a x -- ..b ) -- ..b x ) over [ call ] dip ; inline @@ -129,6 +162,15 @@ DEFER: if : 4keep ( ..a w x y z quot: ( ..a w x y z -- ..b ) -- ..b w x y z ) [ 4dup ] dip 4dip ; inline +: keepd ( ..a x y quot: ( ..a x y -- ..b x ) -- ..b x ) + 2keep drop ; inline + +: keepdd ( ..a x y z quot: ( ..a x y z -- ..b x ) -- ..b x ) + 3keep 2drop ; inline + +: 2keepd ( ..a x y z quot: ( ..a x y z -- ..b x y ) -- ..b x y ) + 3keep drop ; inline + ! Cleavers : bi ( x p q -- ) [ keep ] dip call ; inline diff --git a/core/math/math.factor b/core/math/math.factor index c70a165673..6c66e7d9e3 100644 --- a/core/math/math.factor +++ b/core/math/math.factor @@ -245,50 +245,43 @@ GENERIC: prev-float ( m -- n ) : align ( m w -- n ) 1 - [ + ] keep bitnot bitand ; inline - - : (each-integer) ( ... i n quot: ( ... i -- ... ) -- ... ) - [ iterate-step iterate-next (each-integer) ] - [ 3drop ] if-iterate? ; inline recursive + 2over < [ + [ nip call ] 3keep + [ 1 + ] 2dip (each-integer) + ] [ + 3drop + ] if ; inline recursive : (find-integer) ( ... i n quot: ( ... i -- ... ? ) -- ... i/f ) - [ - iterate-step iterate-rot - [ 2drop ] [ iterate-next (find-integer) ] if - ] [ 3drop f ] if-iterate? ; inline recursive + 2over < [ + [ nip call ] 3keep roll + [ 2drop ] + [ [ 1 + ] 2dip (find-integer) ] if + ] [ + 3drop f + ] if ; inline recursive : (all-integers?) ( ... i n quot: ( ... i -- ... ? ) -- ... ? ) - [ - iterate-step iterate-rot - [ iterate-next (all-integers?) ] [ 3drop f ] if - ] [ 3drop t ] if-iterate? ; inline recursive + 2over < [ + [ nip call ] 3keep roll + [ [ 1 + ] 2dip (all-integers?) ] + [ 3drop f ] if + ] [ + 3drop t + ] if ; inline recursive : each-integer ( ... n quot: ( ... i -- ... ) -- ... ) - iterate-prep (each-integer) ; inline + [ 0 ] 2dip (each-integer) ; inline : times ( ... n quot: ( ... -- ... ) -- ... ) [ drop ] prepose each-integer ; inline : find-integer ( ... n quot: ( ... i -- ... ? ) -- ... i/f ) - iterate-prep (find-integer) ; inline + [ 0 ] 2dip (find-integer) ; inline : all-integers? ( ... n quot: ( ... i -- ... ? ) -- ... ? ) - iterate-prep (all-integers?) ; inline + [ 0 ] 2dip (all-integers?) ; inline : find-last-integer ( ... n quot: ( ... i -- ... ? ) -- ... i/f ) over 0 < [ diff --git a/core/math/parser/parser.factor b/core/math/parser/parser.factor index db8b42c2e4..a450b2b7f0 100644 --- a/core/math/parser/parser.factor +++ b/core/math/parser/parser.factor @@ -309,7 +309,7 @@ DEFER: @neg-digit { [ dup "bB" member-eq? ] [ 2drop 2 ->radix require-next-digit ] } { [ dup "oO" member-eq? ] [ 2drop 8 ->radix require-next-digit ] } { [ dup "xX" member-eq? ] [ 2drop 16 ->radix require-next-digit ] } - [ [ drop ] 2dip swap call ] + [ nipd swap call ] } cond ] 2curry next-digit ; inline diff --git a/core/sequences/sequences.factor b/core/sequences/sequences.factor index 67b20a5886..c40f9c31b0 100644 --- a/core/sequences/sequences.factor +++ b/core/sequences/sequences.factor @@ -90,7 +90,7 @@ M: sequence nth-unsafe nth ; inline M: sequence set-nth-unsafe set-nth ; inline : change-nth-unsafe ( i seq quot -- ) - [ [ nth-unsafe ] dip call ] 3keep drop set-nth-unsafe ; inline + [ [ nth-unsafe ] dip call ] 2keepd set-nth-unsafe ; inline PRIVATE> @@ -380,7 +380,7 @@ PRIVATE> : glue ( seq1 seq2 seq3 -- newseq ) swap 3append ; inline : change-nth ( ..a i seq quot: ( ..a elt -- ..b newelt ) -- ..b ) - [ [ nth ] dip call ] 3keep drop set-nth-unsafe ; inline + [ [ nth ] dip call ] 2keepd set-nth-unsafe ; inline : min-length ( seq1 seq2 -- n ) [ length ] bi@ min ; inline @@ -447,7 +447,7 @@ PRIVATE> if ; inline : (accumulate) ( seq identity quot -- identity seq quot ) - swapd [ curry keep ] curry ; inline + swapd [ keepd ] curry ; inline : (accumulate*) ( seq identity quot -- identity seq quot ) swapd [ dup ] compose ; inline @@ -464,7 +464,7 @@ PRIVATE> swapd each ; inline : map-integers ( ... len quot: ( ... i -- ... elt ) exemplar -- ... newseq ) - [ over ] dip [ [ collect ] keep ] new-like ; inline + overd [ [ collect ] keep ] new-like ; inline : map-as ( ... seq quot: ( ... elt -- ... newelt ) exemplar -- ... newseq ) [ (each) ] dip map-integers ; inline @@ -506,7 +506,7 @@ PRIVATE> [ (2each) ] dip -rot (each-integer) ; inline : 2reduce ( ... seq1 seq2 identity quot: ( ... prev elt1 elt2 -- ... next ) -- ... result ) - [ -rot ] dip 2each ; inline + -rotd 2each ; inline : 2map-as ( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... newelt ) exemplar -- ... newseq ) [ (2each) ] dip map-integers ; inline @@ -524,7 +524,7 @@ PRIVATE> [ (3each) ] dip map-integers ; inline : 3map ( ... seq1 seq2 seq3 quot: ( ... elt1 elt2 elt3 -- ... newelt ) -- ... newseq ) - [ pick ] dip swap 3map-as ; inline + pickd swap 3map-as ; inline : find-from ( ... n seq quot: ( ... elt -- ... ? ) -- ... i elt ) [ (find-integer) ] (find-from) ; inline @@ -793,7 +793,7 @@ PRIVATE> 2over = [ 4drop ] [ - [ [ pick [ dup dup ] dip + swap ] dip move-unsafe 1 - ] keep + [ [ [ ] [ nip + ] [ 2nip ] 3tri ] dip move-unsafe 1 - ] keep move-forward ] if ; @@ -808,7 +808,7 @@ PRIVATE> pick 0 = [ 3drop ] [ - pick over length + over + [ ] [ nip length + ] [ 2nip ] 3tri [ pick 0 > [ [ length ] keep ] dip (open-slice) ] 2dip set-length ] if ; @@ -1089,7 +1089,7 @@ M: repetition sum [ elt>> ] [ length>> ] bi * ; inline [ keep swap ] curry [ [ first ] dip call ] 2keep [ curry 2dip pick over ] curry ] [ - [ [ 2drop ] [ [ 2drop ] 2dip ] if ] compose + [ [ 2drop ] [ 2nipd ] if ] compose ] bi* compose 1 each-from drop ; inline PRIVATE> diff --git a/core/slots/slots.factor b/core/slots/slots.factor index 5560bdcea3..5afaf618d2 100644 --- a/core/slots/slots.factor +++ b/core/slots/slots.factor @@ -212,7 +212,7 @@ M: anonymous-intersection initial-value* { [ pinned-alien bootstrap-word over class<= ] [ t ] } { [ quotation bootstrap-word over class<= ] [ [ ] t ] } [ dup initial-value* ] - } cond [ drop ] 2dip ; + } cond nipd ; GENERIC: make-slot ( desc -- slot-spec ) diff --git a/core/strings/strings.factor b/core/strings/strings.factor index 4bbf642ca0..0a6d1b8a62 100644 --- a/core/strings/strings.factor +++ b/core/strings/strings.factor @@ -56,7 +56,8 @@ PRIVATE> M: string equal? over string? [ - 2dup [ hashcode ] bi@ eq? + ! faster during bootstrap than ``[ hashcode ] bi@`` + over hashcode over hashcode eq? [ sequence= ] [ 2drop f ] if ] [ 2drop f diff --git a/core/words/words.factor b/core/words/words.factor index cee910b3b0..3226df0b1d 100644 --- a/core/words/words.factor +++ b/core/words/words.factor @@ -111,16 +111,17 @@ M: word parent-word drop f ; [ changed-effects get add-to-unit ] [ dup primitive? [ drop ] [ changed-definition ] if ] bi ; -: set-stack-effect ( effect word -- ) - 2dup "declared-effect" word-prop = [ 2drop ] [ - [ nip changed-effect ] - [ nip subwords [ changed-effect ] each ] - [ swap "declared-effect" set-word-prop ] +: set-stack-effect ( word effect -- ) + 2dup [ "declared-effect" word-prop ] dip = + [ 2drop ] [ + [ drop changed-effect ] + [ drop subwords [ changed-effect ] each ] + [ "declared-effect" set-word-prop ] 2tri ] if ; : define-declared ( word def effect -- ) - [ nip swap set-stack-effect ] [ drop define ] 3bi ; + [ nip set-stack-effect ] [ drop define ] 3bi ; : make-deprecated ( word -- ) t "deprecated" set-word-prop ; @@ -200,7 +201,7 @@ M: word reset-word ] tri ; : ( name vocab -- word ) - 2dup [ hashcode ] bi@ hash-combine >fixnum (word) dup new-word ; + over hashcode over hashcode hash-combine >fixnum (word) dup new-word ; : ( name -- word ) f \ counter >fixnum (word) diff --git a/extra/alien/fortran/fortran.factor b/extra/alien/fortran/fortran.factor index 4f0633b5d0..d014bb075b 100755 --- a/extra/alien/fortran/fortran.factor +++ b/extra/alien/fortran/fortran.factor @@ -414,7 +414,7 @@ PRIVATE> : ((fortran-invoke)) ( return library function parameters -- quot ) { [ 2nip [] ] - [ nip nip nip [fortran-args>c-args] ] + [ 3nip [fortran-args>c-args] ] [ [fortran-invoke] ] [ 2nip [fortran-results>] ] } 4 ncleave 4 nappend ; diff --git a/extra/assocs/extras/extras.factor b/extra/assocs/extras/extras.factor index da1c0c2866..27da0347e9 100644 --- a/extra/assocs/extras/extras.factor +++ b/extra/assocs/extras/extras.factor @@ -53,7 +53,7 @@ ERROR: key-exists value key assoc ; ] if ; : kv-with ( obj assoc quot -- assoc curried ) - swapd [ [ -rot ] dip call ] 2curry ; inline + swapd [ -rotd call ] 2curry ; inline : sequence>assoc! ( assoc seq map-quot: ( x -- ..y ) insert-quot: ( ..y assoc -- ) -- assoc ) - 4 nrot (sequence>assoc) ; inline + roll (sequence>assoc) ; inline : assoc>object ( assoc map-quot insert-quot exemplar -- object ) clone [ swap curry compose assoc-each ] keep ; inline : assoc>object! ( assoc seq map-quot: ( x -- ..y ) insert-quot: ( ..y assoc -- ) -- object ) - 4 nrot assoc>object ; inline + roll assoc>object ; inline : sequence>assoc ( seq map-quot insert-quot exemplar -- assoc ) clone (sequence>assoc) ; inline diff --git a/extra/bloom-filters/bloom-filters.factor b/extra/bloom-filters/bloom-filters.factor index 07ff68703a..26e2aa97cf 100644 --- a/extra/bloom-filters/bloom-filters.factor +++ b/extra/bloom-filters/bloom-filters.factor @@ -127,7 +127,7 @@ PRIVATE> : relevant-indices ( object bloom-filter -- n quot: ( elt -- n ) ) [ double-hashcodes ] [ #hashes-and-length ] bi* - [ -rot ] dip '[ _ _ combine-hashcodes _ mod ] ; inline + -rotd '[ _ _ combine-hashcodes _ mod ] ; inline PRIVATE> diff --git a/extra/checksums/sodium/sodium.factor b/extra/checksums/sodium/sodium.factor index cbf124c450..0810016284 100644 --- a/extra/checksums/sodium/sodium.factor +++ b/extra/checksums/sodium/sodium.factor @@ -39,7 +39,7 @@ M: sodium-state get-checksum dup output>> [ dup state>> [ over output-size>> [ ] keep - [ crypto_generichash_final check0 ] 2keep drop + [ crypto_generichash_final check0 ] keepd ] [ B{ } clone ] if* [ >>output ] keep ] unless* nip ; diff --git a/extra/combinators/extras/extras.factor b/extra/combinators/extras/extras.factor index 274c0e860b..3cd42feeb1 100644 --- a/extra/combinators/extras/extras.factor +++ b/extra/combinators/extras/extras.factor @@ -40,9 +40,6 @@ MACRO: cleave-array ( quots -- quot ) : 4tri ( w x y z p q r -- ) [ [ 4keep ] dip 4keep ] dip call ; inline -: keepd ( ..a x y quot: ( ..a x y -- ..b ) -- ..b x ) - 2keep drop ; inline - : plox ( ... x/f quot: ( ... x -- ... ) -- ... ) dupd when ; inline @@ -85,10 +82,10 @@ MACRO:: n-falsify ( n -- quot ) ! try the quot, keep the original arg if quot is true : ?1arg ( obj quot: ( obj -- ? ) -- obj/f ) - [ ?1res ] 2keep drop '[ _ ] [ f ] if ; inline + [ ?1res ] keepd '[ _ ] [ f ] if ; inline : ?2arg ( obj1 obj2 quot: ( obj1 obj2 -- ? ) -- obj1/f obj2/f ) - [ ?2res ] 3keep drop '[ _ _ ] [ f f ] if ; inline + [ ?2res ] 2keepd '[ _ _ ] [ f f ] if ; inline << : alist>quot* ( default assoc -- quot ) diff --git a/extra/compiler/cfg/gvn/simd/simd.factor b/extra/compiler/cfg/gvn/simd/simd.factor index 24b59deb0d..667d750f26 100644 --- a/extra/compiler/cfg/gvn/simd/simd.factor +++ b/extra/compiler/cfg/gvn/simd/simd.factor @@ -92,8 +92,8 @@ M: ##gather-int-vector-2 rewrite rewrite-gather-vector-2 ; : rewrite-gather-vector-4 ( insn -- insn/f ) dup { [ src1>> ] [ src2>> ] [ src3>> ] [ src4>> ] } cleave [ vreg>insn ] 4 napply { - { [ 4 ndup [ literal-insn? ] 4 napply and and and ] [ fold-gather-vector-4 ] } - [ 5 ndrop f ] + { [ 4dup [ literal-insn? ] 4 napply and and and ] [ fold-gather-vector-4 ] } + [ 5drop f ] } cond ; M: ##gather-vector-4 rewrite rewrite-gather-vector-4 ; diff --git a/extra/cpu/8080/test/test.factor b/extra/cpu/8080/test/test.factor index de093ac059..d6599f7a5d 100644 --- a/extra/cpu/8080/test/test.factor +++ b/extra/cpu/8080/test/test.factor @@ -55,7 +55,7 @@ IN: cpu.8080.test 224 [ 32 [ over 32 * over + 0x2400 + ! cpu h w addr - [ pick ] dip swap ram>> nth [ + reach ram>> nth [ [ " 0 0 0" write ] [ diff --git a/extra/crypto/aes/utils/utils.factor b/extra/crypto/aes/utils/utils.factor index cd98113d77..06787bae88 100644 --- a/extra/crypto/aes/utils/utils.factor +++ b/extra/crypto/aes/utils/utils.factor @@ -40,18 +40,16 @@ IN: crypto.aes.utils : first-diag ( c0 c1 c2 c3 -- a0 a1 a2 a3 ) { [ gb3 ] [ gb2 ] [ gb1 ] [ gb0 ] } spread ; -: (4rot) ( c0 c1 c2 c3 -- c1 c2 c3 c0 ) 4 nrot ; inline -: second-diag ( c0 c1 c2 c3 -- a0 a1 a2 a3 ) (4rot) first-diag ; -: third-diag ( c0 c1 c2 c3 -- a0 a1 a2 a3 ) (4rot) second-diag ; -: fourth-diag ( c0 c1 c2 c3 -- a0 a1 a2 a3 ) (4rot) third-diag ; +: second-diag ( c0 c1 c2 c3 -- a0 a1 a2 a3 ) roll first-diag ; +: third-diag ( c0 c1 c2 c3 -- a0 a1 a2 a3 ) roll second-diag ; +: fourth-diag ( c0 c1 c2 c3 -- a0 a1 a2 a3 ) roll third-diag ; ! given 4 columns, output the first reverse diagonal, i.e. ! C[0,0] C[3,1] C[2,2] C[1,3] -:: (-rev) ( c0 c1 c2 c3 -- c0 c3 c2 c1 ) c0 c3 c2 c1 ; inline -: -first-diag ( c0 c1 c2 c3 -- a0 a1 a2 a3 ) (-rev) first-diag ; -: -second-diag ( c0 c1 c2 c3 -- a0 a1 a2 a3 ) (-rev) (4rot) first-diag ; -: -third-diag ( c0 c1 c2 c3 -- a0 a1 a2 a3 ) (-rev) (4rot) second-diag ; -: -fourth-diag ( c0 c1 c2 c3 -- a0 a1 a2 a3 ) (-rev) (4rot) third-diag ; +: -first-diag ( c0 c1 c2 c3 -- a0 a1 a2 a3 ) spin first-diag ; +: -second-diag ( c0 c1 c2 c3 -- a0 a1 a2 a3 ) spin roll first-diag ; +: -third-diag ( c0 c1 c2 c3 -- a0 a1 a2 a3 ) spin roll second-diag ; +: -fourth-diag ( c0 c1 c2 c3 -- a0 a1 a2 a3 ) spin roll third-diag ; :: set-first4-unsafe ( seq a0 a1 a2 a3 -- ) a0 0 seq set-nth-unsafe diff --git a/extra/cuda/devices/devices.factor b/extra/cuda/devices/devices.factor index 5706ba783d..389aba9539 100644 --- a/extra/cuda/devices/devices.factor +++ b/extra/cuda/devices/devices.factor @@ -21,7 +21,7 @@ IN: cuda.devices : cuda-device-properties ( n -- properties ) [ CUdevprop ] dip - [ cuDeviceGetProperties cuda-error ] 2keep drop ; + [ cuDeviceGetProperties cuda-error ] keepd ; : cuda-devices ( -- assoc ) enumerate-cuda-devices [ dup cuda-device-properties ] { } map>assoc ; diff --git a/extra/cursors/cursors.factor b/extra/cursors/cursors.factor index a5d55aefb6..2d8eb9f533 100644 --- a/extra/cursors/cursors.factor +++ b/extra/cursors/cursors.factor @@ -574,7 +574,7 @@ MACRO: -nin- ( n -- quot ) ! : -with- ( invariant begin end quot -- begin end quot' ) - [ rot ] dip '[ [ _ ] dip @ ] ; inline + rotd '[ [ _ ] dip @ ] ; inline : -2with- ( invariant invariant begin end quot -- begin end quot' ) -with- -with- ; inline diff --git a/extra/euler/b-rep/b-rep.factor b/extra/euler/b-rep/b-rep.factor index 57234f5659..ef0df0b5cc 100644 --- a/extra/euler/b-rep/b-rep.factor +++ b/extra/euler/b-rep/b-rep.factor @@ -94,7 +94,7 @@ sharpness-stack [ V{ t } ] initialize [ face-ccw ] keep [ vertex-pos ] bi@ v- ; : normal ( v0 v1 v2 -- v ) - [ drop v- ] [ [ drop ] 2dip v- ] 3bi cross ; + [ drop v- ] [ nipd v- ] 3bi cross ; ERROR: all-points-colinear ; diff --git a/extra/fluids/fluids.factor b/extra/fluids/fluids.factor index 21e3b24278..20a2033c7f 100644 --- a/extra/fluids/fluids.factor +++ b/extra/fluids/fluids.factor @@ -60,7 +60,7 @@ TUPLE: fluids-world < game-world ] [ - 0 swap [ allocate-texture-image ] 3keep 2drop + 0 swap [ allocate-texture-image ] keepdd ] bi ; SYMBOL: fluid diff --git a/extra/game/models/collada/collada.factor b/extra/game/models/collada/collada.factor index 18773e79a4..77db0a505e 100644 --- a/extra/game/models/collada/collada.factor +++ b/extra/game/models/collada/collada.factor @@ -72,7 +72,7 @@ M: z-up >y-up-axis! [ "float_array" x/ xt string>numbers [ * ] with map ] [ nip "technique_common" x/ "accessor" x/ "stride" x@ string>number ] 2bi group - [ swap over length 2 > [ >y-up-axis! ] [ drop ] if ] with map ; + [ tuck length 2 > [ >y-up-axis! ] [ drop ] if ] with map ; : source>pair ( source-tag -- pair ) [ "id" x@ ] diff --git a/extra/gml/coremath/coremath.factor b/extra/gml/coremath/coremath.factor index 3a4d72d153..5db5b75e0a 100644 --- a/extra/gml/coremath/coremath.factor +++ b/extra/gml/coremath/coremath.factor @@ -43,10 +43,10 @@ FROM: generalizations => npick ; : gml-scalar-op ( a b scalar-quot mixed-quot vector-quot -- c ) { - { [ 4 npick float? ] [ 2drop call ] } - { [ 4 npick integer? ] [ 2drop call ] } - { [ 4 npick vec2d? ] [ drop nip [ scalar>vec2d ] 2dip call ] } - { [ 4 npick vec3d? ] [ drop nip [ scalar>vec3d ] 2dip call ] } + { [ reach float? ] [ 2drop call ] } + { [ reach integer? ] [ 2drop call ] } + { [ reach vec2d? ] [ drop nip [ scalar>vec2d ] 2dip call ] } + { [ reach vec3d? ] [ drop nip [ scalar>vec3d ] 2dip call ] } } cond ; inline : gml-math-op ( a b scalar-quot mixed-quot vector-quot -- c ) @@ -55,16 +55,16 @@ FROM: generalizations => npick ; { [ 5 npick integer? ] [ gml-scalar-op ] } { [ 5 npick vec2d? ] [ { - { [ 4 npick vec2d? ] [ 2nip call ] } - { [ 4 npick float? ] [ drop nip [ scalar>vec2d ] dip call ] } - { [ 4 npick integer? ] [ drop nip [ scalar>vec2d ] dip call ] } + { [ reach vec2d? ] [ 2nip call ] } + { [ reach float? ] [ drop nip [ scalar>vec2d ] dip call ] } + { [ reach integer? ] [ drop nip [ scalar>vec2d ] dip call ] } } cond ] } { [ 5 npick vec3d? ] [ { - { [ 4 npick vec3d? ] [ 2nip call ] } - { [ 4 npick float? ] [ drop nip [ scalar>vec3d ] dip call ] } - { [ 4 npick integer? ] [ drop nip [ scalar>vec3d ] dip call ] } + { [ reach vec3d? ] [ 2nip call ] } + { [ reach float? ] [ drop nip [ scalar>vec3d ] dip call ] } + { [ reach integer? ] [ drop nip [ scalar>vec3d ] dip call ] } } cond ] } } cond ; inline diff --git a/extra/gpu/render/render.factor b/extra/gpu/render/render.factor index 7761669eec..e37f498b7d 100755 --- a/extra/gpu/render/render.factor +++ b/extra/gpu/render/render.factor @@ -554,7 +554,7 @@ SYNTAX: UNIFORM-TUPLE: : bind-output-attachments ( program-instance framebuffer attachments -- ) dup first sequence? - [ bind-named-output-attachments ] [ [ drop ] 2dip bind-unnamed-output-attachments ] if ; + [ bind-named-output-attachments ] [ nipd bind-unnamed-output-attachments ] if ; GENERIC: bind-transform-feedback-output ( output -- ) diff --git a/extra/html/parser/utils/utils.factor b/extra/html/parser/utils/utils.factor index 0b9474a7f1..ddb7a062b3 100644 --- a/extra/html/parser/utils/utils.factor +++ b/extra/html/parser/utils/utils.factor @@ -4,7 +4,7 @@ USING: kernel quoting sequences splitting ; IN: html.parser.utils : trim1 ( seq ch -- newseq ) - [ [ ?head-slice drop ] [ ?tail-slice drop ] bi ] 2keep drop like ; + [ [ ?head-slice drop ] [ ?tail-slice drop ] bi ] keepd like ; : single-quote ( str -- newstr ) "'" dup surround ; diff --git a/extra/imap/imap.factor b/extra/imap/imap.factor index b2db9b5d01..892b94de44 100644 --- a/extra/imap/imap.factor +++ b/extra/imap/imap.factor @@ -27,7 +27,7 @@ CONSTANT: IMAP4_SSL_PORT 993 ! Date, month, year. "-" read-token checked-number "-" read-token month-abbreviations index 1 + - read-sp checked-number -rot swap + read-sp checked-number spin ! Hour, minute second and gmt offset. read-hms " " expect readln parse-rfc822-gmt-offset ] with-string-reader ; diff --git a/extra/io/files/trash/unix/unix.factor b/extra/io/files/trash/unix/unix.factor index d24dec443b..1d27d44000 100644 --- a/extra/io/files/trash/unix/unix.factor +++ b/extra/io/files/trash/unix/unix.factor @@ -70,7 +70,7 @@ M: unix send-to-trash ( path -- ) to-directory safe-file-name ] [ "info" append-path [ make-user-directory ] keep - to-directory ".trashinfo" append [ over ] dip utf8 [ + to-directory ".trashinfo" append overd utf8 [ "[Trash Info]" write nl "Path=" write write nl "DeletionDate=" write diff --git a/extra/irc/messages/base/base.factor b/extra/irc/messages/base/base.factor index f5d3f50c6e..9ba613f2fa 100644 --- a/extra/irc/messages/base/base.factor +++ b/extra/irc/messages/base/base.factor @@ -102,7 +102,7 @@ M: irc-message set-irc-command [ irc-message ] dip define-tuple-class ; : define-irc-parameter-slots ( class params -- ) - { ":" } split1 [ over ] dip + { ":" } split1 overd [ ?define-irc-parameters ] [ ?define-irc-trailing ] 2bi* ; PRIVATE> diff --git a/extra/jamshred/player/player.factor b/extra/jamshred/player/player.factor index 0abb9c097b..1d17f31563 100644 --- a/extra/jamshred/player/player.factor +++ b/extra/jamshred/player/player.factor @@ -25,7 +25,7 @@ CONSTANT: max-speed 30.0 f f 0 default-speed player boa ; : turn-player ( player x-radians y-radians -- ) - [ over ] dip left-pivot up-pivot ; + overd left-pivot up-pivot ; : roll-player ( player z-radians -- ) forward-pivot ; diff --git a/extra/ldcache/ldcache.factor b/extra/ldcache/ldcache.factor index e185f5d675..71c85197e6 100644 --- a/extra/ldcache/ldcache.factor +++ b/extra/ldcache/ldcache.factor @@ -42,7 +42,7 @@ STRUCT: EntryNew [ magic>> ] dip [ >byte-array ] bi@ check-magic ; : make-string ( string-table i -- str ) - 0 rot swapd [ index-from ] 2keep swapd subseq + 0 spin [ index-from ] 2keep swapd subseq native-string-encoding decode ; : string-offset ( header-new -- n ) diff --git a/extra/lint/lint.factor b/extra/lint/lint.factor index 82ad561207..9e47a5877f 100644 --- a/extra/lint/lint.factor +++ b/extra/lint/lint.factor @@ -18,6 +18,8 @@ CONSTANT: manual-substitutions { over [ dup swap ] } { swapd [ [ swap ] dip ] } { 2nip [ nip nip ] } + { 3nip [ 2nip nip ] } + { 4nip [ 3nip nip ] } { 2drop [ drop drop ] } { 3drop [ drop drop drop ] } { pop* [ pop drop ] } @@ -144,7 +146,7 @@ CONSTANT: trivial-defs [ { [ length 4 <= ] - [ first { drop 2drop 3drop nip 2nip } member? ] + [ first { drop 2drop 3drop nip 2nip 3nip 4nip } member? ] [ rest-slice [ boolean? ] all? ] } 1&& ] diff --git a/extra/math/combinatorics/bits/bits.factor b/extra/math/combinatorics/bits/bits.factor index 2d8aabde0a..23c62c9bda 100644 --- a/extra/math/combinatorics/bits/bits.factor +++ b/extra/math/combinatorics/bits/bits.factor @@ -33,4 +33,4 @@ PRIVATE> while drop swap and ; inline : reduce-permutation-bits ( ... bit-count bits identity quot: ( ... prev elt -- ... next ) -- ... result ) - [ -rot ] dip each-permutation-bits ; inline + -rotd each-permutation-bits ; inline diff --git a/extra/math/dual/dual.factor b/extra/math/dual/dual.factor index 4512eb8f76..2f716dfd5e 100644 --- a/extra/math/dual/dual.factor +++ b/extra/math/dual/dual.factor @@ -36,10 +36,8 @@ MACRO: ordinary-op ( word -- o ) MACRO: duals>nweave ( n -- quot ) dup dup dup '[ - [ [ epsilon-part>> ] _ napply ] - _ nkeep - [ ordinary-part>> ] _ napply - _ nweave + [ [ epsilon-part>> ] _ napply ] _ nkeep + [ ordinary-part>> ] _ napply _ nweave ] ; MACRO: chain-rule ( word -- e ) @@ -49,18 +47,19 @@ MACRO: chain-rule ( word -- e ) tri '[ [ @ _ @ ] sum-outputs ] ; -: set-dual-help ( word dword -- ) - [ swap - [ stack-effect [ in>> ] [ out>> ] bi append +: set-dual-help ( dword word -- ) + [ + [ + stack-effect [ in>> ] [ out>> ] bi append [ dual ] { } map>assoc { $values } prepend - ] - [ [ { $description } % "Version of " , - { $link } swap suffix , - " extended to work on dual numbers." , ] - { } make - ] - bi* 2array - ] keep set-word-help ; + ] [ + [ + { $description } % "Version of " , + { $link } swap suffix , + " extended to work on dual numbers." , + ] { } make + ] bi* 2array + ] keepd set-word-help ; PRIVATE> @@ -72,12 +71,12 @@ MACRO: dual-op ( word -- quot ) '[ _ @ @ ] ; : define-dual ( word -- ) - dup name>> "d" prepend "math.dual" create-word - [ [ stack-effect ] dip set-stack-effect ] + [ name>> "d" prepend "math.dual" create-word ] keep + [ stack-effect set-stack-effect ] [ set-dual-help ] - [ swap '[ _ dual-op ] define ] + [ '[ _ dual-op ] define ] 2tri ; ! Specialize math functions to operate on dual numbers. [ all-words [ "derivative" word-prop ] filter - [ define-dual ] each ] with-compilation-unit +[ define-dual ] each ] with-compilation-unit diff --git a/extra/math/similarity/similarity.factor b/extra/math/similarity/similarity.factor index a2c4a676e3..52c5027ada 100644 --- a/extra/math/similarity/similarity.factor +++ b/extra/math/similarity/similarity.factor @@ -27,4 +27,4 @@ PRIVATE> : weighted-cosine-similarity ( w a b -- n ) [ weighted-v. ] - [ [ over ] dip [ weighted-norm ] 2bi@ * ] 3bi / ; + [ overd [ weighted-norm ] 2bi@ * ] 3bi / ; diff --git a/extra/midi/midi.factor b/extra/midi/midi.factor index 3f8ccf4e5a..4a199111ee 100644 --- a/extra/midi/midi.factor +++ b/extra/midi/midi.factor @@ -210,7 +210,7 @@ CONSTANT: smpte-framerate H{ binary [ f [ peek1 [ read-event-header ] [ f f ] if dup - ] [ read-event ] produce 2nip nip + ] [ read-event ] produce 3nip ] with-input-stream ; : ( bytes -- header ) diff --git a/extra/model-viewer/model-viewer.factor b/extra/model-viewer/model-viewer.factor index b7e518522a..4ccd6eb3f3 100644 --- a/extra/model-viewer/model-viewer.factor +++ b/extra/model-viewer/model-viewer.factor @@ -113,7 +113,7 @@ TUPLE: vbo ] [ - 0 swap [ allocate-texture-image ] 3keep 2drop + 0 swap [ allocate-texture-image ] keepdd ] bi ; : ( models -- buffers ) @@ -184,8 +184,8 @@ TUPLE: vbo [ { { "primitive-mode" [ 3drop triangles-mode ] } - { "uniforms" [ nip nip ] } - { "vertex-array" [ drop drop ] } + { "uniforms" [ 2nip ] } + { "vertex-array" [ 2drop ] } { "indexes" [ drop nip ] } } 3 render ] 3each ; diff --git a/extra/mongodb/tuple/persistent/persistent.factor b/extra/mongodb/tuple/persistent/persistent.factor index 78fb5d8cce..f9ba6cdf4a 100644 --- a/extra/mongodb/tuple/persistent/persistent.factor +++ b/extra/mongodb/tuple/persistent/persistent.factor @@ -42,7 +42,7 @@ DEFER: assoc>tuple : write-field? ( tuple key value -- ? ) pick mdb-persistent? [ - { [ [ 2drop ] dip not ] + { [ 2nip not ] [ drop transient-slot? ] } 3|| not ] [ 3drop t ] if ; inline TUPLE: cond-value value quot ; diff --git a/extra/multi-methods/multi-methods.factor b/extra/multi-methods/multi-methods.factor index 6a362bbef1..7f1505d65a 100644 --- a/extra/multi-methods/multi-methods.factor +++ b/extra/multi-methods/multi-methods.factor @@ -216,7 +216,7 @@ M: no-method error. [ "multi-method-generic" word-prop ] bi prefix ; : define-generic ( word effect -- ) - over set-stack-effect + [ set-stack-effect ] keepd dup "multi-methods" word-prop [ drop ] [ [ H{ } clone "multi-methods" set-word-prop ] [ update-generic ] diff --git a/extra/multi-methods/tests/definitions.factor b/extra/multi-methods/tests/definitions.factor index 4b34513017..9ef63e4654 100644 --- a/extra/multi-methods/tests/definitions.factor +++ b/extra/multi-methods/tests/definitions.factor @@ -4,7 +4,7 @@ IN: multi-methods.tests DEFER: fake \ fake H{ } clone "multi-methods" set-word-prop -<< ( -- ) \ fake set-stack-effect >> +<< \ fake ( -- ) set-stack-effect >> [ [ "fake-{ }" ] [ { } \ fake method-word-name ] unit-test diff --git a/extra/noise/noise.factor b/extra/noise/noise.factor index 92ecdbc434..252a1368a2 100644 --- a/extra/noise/noise.factor +++ b/extra/noise/noise.factor @@ -58,7 +58,7 @@ ERROR: invalid-perlin-noise-table table ; ! XXX doesn't work when v is nan or |v| >= 2^31 : floor-vector ( v -- v' ) [ float-4 int-4 vconvert int-4 float-4 vconvert ] - [ [ v> -1.0 float-4-with vand ] curry keep v+ ] bi ; inline + [ [ v> -1.0 float-4-with vand ] keepd v+ ] bi ; inline : unit-cubed ( floats -- ints ) float-4 int-4 vconvert 255 int-4-with vbitand ; inline diff --git a/extra/openal/alut/alut.factor b/extra/openal/alut/alut.factor index f4ae603f68..97bedc4c47 100755 --- a/extra/openal/alut/alut.factor +++ b/extra/openal/alut/alut.factor @@ -95,7 +95,7 @@ os macosx? "openal.alut.macosx" "openal.alut.other" ? require : create-buffer-from-wav ( filename -- buffer ) gen-buffer dup rot load-wav-file - [ alBufferData ] 4 nkeep alutUnloadWAV ; + [ alBufferData ] 4keep alutUnloadWAV ; : check-error ( -- ) alGetError dup ALUT_ERROR_NO_ERROR = [ diff --git a/extra/openal/alut/macosx/macosx.factor b/extra/openal/alut/macosx/macosx.factor index e0cc7c5a03..c10c5a2281 100755 --- a/extra/openal/alut/macosx/macosx.factor +++ b/extra/openal/alut/macosx/macosx.factor @@ -10,5 +10,5 @@ FUNCTION: void alutLoadWAVFile ( c-string fileName, ALenum* format, void** data, M: macosx load-wav-file ( path -- format data size frequency ) 0 int f void* 0 int 0 int - [ alutLoadWAVFile ] 4 nkeep + [ alutLoadWAVFile ] 4keep [ [ [ int deref ] dip void* deref ] dip int deref ] dip int deref ; diff --git a/extra/openal/alut/other/other.factor b/extra/openal/alut/other/other.factor index c2d7d1f23c..874dce17b9 100755 --- a/extra/openal/alut/other/other.factor +++ b/extra/openal/alut/other/other.factor @@ -13,5 +13,5 @@ M: object load-wav-file ( filename -- format data size frequency ) f void* 0 int 0 int - [ 0 char alutLoadWAVFile ] 4 nkeep + [ 0 char alutLoadWAVFile ] 4keep { [ int deref ] [ void* deref ] [ int deref ] [ int deref ] } spread ; diff --git a/extra/opencl/opencl.factor b/extra/opencl/opencl.factor index 8325be9a9c..db3e64fc1e 100644 --- a/extra/opencl/opencl.factor +++ b/extra/opencl/opencl.factor @@ -19,19 +19,21 @@ ERROR: cl-error err ; dup f = [ cl-error ] [ drop ] if ; inline : info-data-size ( handle name info-quot -- size_t ) - [ 0 f 0 size_t ] dip [ call cl-success ] 2keep drop size_t deref ; inline + [ 0 f 0 size_t ] dip + [ call cl-success ] keepd size_t deref ; inline : info-data-bytes ( handle name info-quot size -- bytes ) - swap [ dup f ] dip [ call cl-success ] 3keep 2drop ; inline + swap [ dup f ] dip [ call cl-success ] keepdd ; inline : info ( handle name info-quot lift-quot -- value ) [ 3dup info-data-size info-data-bytes ] dip call ; inline : 2info-data-size ( handle1 handle2 name info-quot -- size_t ) - [ 0 f 0 size_t ] dip [ call cl-success ] 2keep drop size_t deref ; inline + [ 0 f 0 size_t ] dip + [ call cl-success ] keepd size_t deref ; inline : 2info-data-bytes ( handle1 handle2 name info-quot size -- bytes ) - swap [ dup f ] dip [ call cl-success ] 3keep 2drop ; inline + swap [ dup f ] dip [ call cl-success ] keepdd ; inline : 2info ( handle1 handle2 name info_quot lift_quot -- value ) [ 4dup 2info-data-size 2info-data-bytes ] dip call ; inline @@ -463,7 +465,7 @@ PRIVATE> : ( buffer-access-mode size initial-data -- buffer ) [ (current-cl-context) ] 3dip - swap over [ + tuck [ [ handle>> ] [ buffer-access-constant ] [ [ CL_MEM_COPY_HOST_PTR ] [ CL_MEM_ALLOC_HOST_PTR ] if ] tri* bitor diff --git a/extra/opengl/demo-support/demo-support.factor b/extra/opengl/demo-support/demo-support.factor index 4be6bc2781..852e53b367 100644 --- a/extra/opengl/demo-support/demo-support.factor +++ b/extra/opengl/demo-support/demo-support.factor @@ -46,7 +46,7 @@ M: demo-world pref-dim* ( gadget -- dim ) [ near-plane ] [ far-plane ] [ fov-ratio ] tri [ nip swap FOV / v*n first2 [ -+ ] bi@ - ] 3keep drop ; + ] 2keepd ; M: demo-world resize-world GL_PROJECTION glMatrixMode @@ -88,7 +88,7 @@ M: demo-world resize-world over first2 glVertex2d dup first pick second glVertex2d dup first2 glVertex2d - swap first swap second glVertex2d + [ first ] [ second ] bi* glVertex2d ] do-state ; demo-world H{ diff --git a/extra/pair-methods/pair-methods.factor b/extra/pair-methods/pair-methods.factor index 523ff3a57a..4bc26e3477 100644 --- a/extra/pair-methods/pair-methods.factor +++ b/extra/pair-methods/pair-methods.factor @@ -33,7 +33,7 @@ ERROR: no-pair-method a b generic ; dup pair-generic-definition define ; : define-pair-generic ( word effect -- ) - [ swap set-stack-effect ] + [ set-stack-effect ] [ drop H{ } clone "pair-generic-methods" set-word-prop ] [ drop make-pair-generic ] 2tri ; diff --git a/extra/pcre/pcre.factor b/extra/pcre/pcre.factor index 5759c1b3ec..f30f70a71f 100644 --- a/extra/pcre/pcre.factor +++ b/extra/pcre/pcre.factor @@ -90,7 +90,7 @@ ERROR: pcre-error value ; 0 { c-string } [ pcre_study ] with-out-parameters drop ; : exec ( pcre extra subject ofs opts -- count match-data ) - [ dup length ] 2dip 30 int 30 [ pcre_exec ] 2keep drop ; + [ dup length ] 2dip 30 int 30 [ pcre_exec ] keepd; TUPLE: matcher pcre extra subject ofs exec-opts ; diff --git a/extra/pdf/layout/layout.factor b/extra/pdf/layout/layout.factor index cb077e3afa..6cbaa919eb 100644 --- a/extra/pdf/layout/layout.factor +++ b/extra/pdf/layout/layout.factor @@ -149,7 +149,7 @@ M: hr pdf-render [ [ dup 0 > pick avail-lines 0 > and ] [ over avail-width over min [ - ] keep [ - [ over ] dip [ draw-line ] [ inc-x ] 2bi + overd [ draw-line ] [ inc-x ] 2bi ] unless-zero dup 0 > [ over line-break ] when ] while ] change-width nip dup width>> 0 > [ drop f ] unless ; diff --git a/extra/project-euler/002/002.factor b/extra/project-euler/002/002.factor index 201e4f6743..01637f381e 100644 --- a/extra/project-euler/002/002.factor +++ b/extra/project-euler/002/002.factor @@ -41,7 +41,7 @@ PRIVATE> ! ------------------- : fib-upto* ( n -- seq ) - 0 1 [ pick over >= ] [ [ nip ] 2keep + dup ] produce [ 3drop ] dip + 0 1 [ pick over >= ] [ [ nip ] 2keep + dup ] produce 3nip but-last-slice { 0 1 } prepend ; : euler002a ( -- answer ) diff --git a/extra/project-euler/009/009.factor b/extra/project-euler/009/009.factor index f75950520d..7099a5571b 100644 --- a/extra/project-euler/009/009.factor +++ b/extra/project-euler/009/009.factor @@ -37,7 +37,7 @@ IN: project-euler.009 ] { } make natural-sort ; : (ptriplet) ( target p q triplet -- target p q ) - sum [ pick ] dip = [ next-pq 2dup abc (ptriplet) ] unless ; + sum pickd = [ next-pq 2dup abc (ptriplet) ] unless ; : ptriplet ( target -- triplet ) 3 1 { 3 4 5 } (ptriplet) abc nip ; diff --git a/extra/python/python.factor b/extra/python/python.factor index 12e92a8c79..73950c8933 100644 --- a/extra/python/python.factor +++ b/extra/python/python.factor @@ -109,7 +109,7 @@ ERROR: missing-type type ; ! Callbacks : quot>py-callback ( quot: ( args kw -- ret ) -- alien ) '[ - [ nip ] dip + nipd [ [ py> ] [ { } ] if* ] bi@ @ >py ] PyCallback ; inline diff --git a/extra/rosetta-code/bulls-and-cows/bulls-and-cows.factor b/extra/rosetta-code/bulls-and-cows/bulls-and-cows.factor index d9a02ecd84..7e6294a75d 100644 --- a/extra/rosetta-code/bulls-and-cows/bulls-and-cows.factor +++ b/extra/rosetta-code/bulls-and-cows/bulls-and-cows.factor @@ -37,8 +37,8 @@ TUPLE: cow ; TUPLE: bull ; : ( -- bull ) bull new ; -: inc-bulls ( score -- score ) dup bulls>> 1 + >>bulls ; -: inc-cows ( score -- score ) dup cows>> 1 + >>cows ; +: inc-bulls ( score -- score ) [ 1 + ] change-bulls ; +: inc-cows ( score -- score ) [ 1 + ] change-cows ; : random-nums ( -- seq ) 9 [1,b] 4 sample ; @@ -66,23 +66,26 @@ TUPLE: bull ; : sum-score ( n g -- score ? ) '[ _ cow-or-bull ] map sift add-to-score dup check-win ; -: print-sum ( score -- str ) - dup bulls>> number>string "Bulls: " swap append swap cows>> number>string - " Cows: " swap 3append "\n" append ; +: score-to-answer ( score -- str ) + [ bulls>> number>string "Bulls: " prepend ] + [ cows>> number>string " Cows: " prepend ] bi "\n" glue ; -: (validate-readln) ( str -- ? ) dup length 4 = not swap [ letter? ] all? or ; +: (validate-readln) ( str -- ? ) + [ length 4 = not ] + [ [ letter? ] all? ] bi or ; : validate-readln ( -- str ) readln dup (validate-readln) - [ "Invalid input.\nPlease enter a valid 4 digit number: " - write flush drop validate-readln ] - when ; + [ + "Invalid input.\nPlease enter a valid 4 digit number: " + write flush drop validate-readln + ] when ; -: win ( -- ) "\nYou've won! Good job. You're so smart." print flush ; +: win ( -- ) "You've won! Good job. You're so smart." print flush ; : main-loop ( x -- ) "Enter a 4 digit number: " write flush validate-readln num>hash swap - [ sum-score swap print-sum print flush ] keep swap not + [ sum-score swap score-to-answer print flush ] keep swap not [ main-loop ] [ drop win ] if ; : bulls-and-cows-main ( -- ) new-number drop narr>nhash main-loop ; diff --git a/extra/rosetta-code/raycasting/raycasting.factor b/extra/rosetta-code/raycasting/raycasting.factor index ca3849ada4..546e53195d 100644 --- a/extra/rosetta-code/raycasting/raycasting.factor +++ b/extra/rosetta-code/raycasting/raycasting.factor @@ -111,7 +111,7 @@ IN: rosetta-code.raycasting : lincomb ( a b x -- w ) 3dup [ last ] tri@ [ - ] curry bi@ - [ drop ] 2dip + nipd neg 2dup + [ / ] curry bi@ [ [ v*n ] curry ] bi@ bi* v+ ; diff --git a/extra/sequences/extras/extras.factor b/extra/sequences/extras/extras.factor index f8671a254d..334fc60b3f 100644 --- a/extra/sequences/extras/extras.factor +++ b/extra/sequences/extras/extras.factor @@ -36,7 +36,7 @@ IN: sequences.extras : filter-all-subseqs-range ( ... seq range quot: ( ... subseq -- ... ) -- seq ) [ '[ _ filter ] with map concat - ] 3keep 2drop map-like ; inline + ] keepdd map-like ; inline : filter-all-subseqs ( ... seq quot: ( ... subseq -- ... ) -- seq ) [ dup length [1,b] ] dip filter-all-subseqs-range ; inline @@ -72,7 +72,7 @@ IN: sequences.extras [ change-nth ] 2curry each ; inline : push-if-index ( ..a elt i quot: ( ..a elt i -- ..b ? ) accum -- ..b ) - [ 2keep drop ] dip rot [ push ] [ 2drop ] if ; inline + [ keepd ] dip rot [ push ] [ 2drop ] if ; inline : push-if* ( ..a elt quot: ( ..a elt -- ..b obj/f ) accum -- ..b ) [ call ] dip [ push ] [ drop ] if* ; inline @@ -236,7 +236,7 @@ PRIVATE> ] if ; inline : map-filter-as ( ... seq map-quot: ( ... elt -- ... newelt ) filter-quot: ( ... newelt -- ... ? ) exemplar -- ... subseq ) - [ pick ] dip swap length over + reach length over [ (selector-as) [ compose each ] dip ] 2curry dip like ; inline : map-filter ( ... seq map-quot: ( ... elt -- ... newelt ) filter-quot: ( ... newelt -- ... ? ) -- ... subseq ) @@ -281,7 +281,7 @@ PRIVATE> PRIVATE> : filter-map-as ( ... seq filter-quot: ( ... elt -- ... ? ) map-quot: ( ... elt -- ... newelt ) exemplar -- ... newseq ) - [ pick ] dip swap length over + reach length over [ (filter-mapper-for) [ each ] dip ] 2curry dip like ; inline : filter-map ( ... seq filter-quot: ( ... elt -- ... ? ) map-quot: ( ... elt -- ... newelt ) -- ... newseq ) @@ -538,7 +538,7 @@ PRIVATE> } case ; : cut-when ( ... seq quot: ( ... elt -- ... ? ) -- ... before after ) - [ find drop ] 2keep drop swap + [ find drop ] keepd swap [ cut ] [ f over like ] if* ; inline : nth* ( n seq -- elt ) @@ -621,11 +621,11 @@ PRIVATE> '[ swap _ dip swap ] assoc-map ; inline : take-while ( ... seq quot: ( ... elt -- ... ? ) -- head-slice ) - [ '[ @ not ] find drop ] 2keep drop swap + [ '[ @ not ] find drop ] keepd swap [ dup length ] unless* head-slice ; inline : drop-while ( ... seq quot: ( ... elt -- ... ? ) -- tail-slice ) - [ '[ @ not ] find drop ] 2keep drop swap + [ '[ @ not ] find drop ] keepd swap [ dup length ] unless* tail-slice ; inline :: interleaved-as ( seq glue exemplar -- newseq ) diff --git a/extra/shell/parser/parser.factor b/extra/shell/parser/parser.factor index f6ffbf03af..0608480b62 100644 --- a/extra/shell/parser/parser.factor +++ b/extra/shell/parser/parser.factor @@ -21,7 +21,7 @@ TUPLE: factor-expr expr ; suffix swap prefix >>commands over second >>stdin over 5 swap nth >>stdout - swap 6 swap nth >>background ; + 6 rot nth >>background ; : ast>single-quoted-expr ( ast -- obj ) second >string single-quoted-expr boa ; diff --git a/extra/taxes/usa/federal/federal.factor b/extra/taxes/usa/federal/federal.factor index fcddd58b6b..66387a2882 100644 --- a/extra/taxes/usa/federal/federal.factor +++ b/extra/taxes/usa/federal/federal.factor @@ -42,7 +42,7 @@ M: federal adjust-allowances* ( salary w4 collector entity -- newsalary ) M: federal withholding* ( salary w4 tax-table entity -- x ) drop - [ federal-tax ] 3keep drop + [ federal-tax ] 2keepd [ fica-tax ] 2keep medicare-tax + + ; diff --git a/extra/tetris/gl/gl.factor b/extra/tetris/gl/gl.factor index d5aed2fca2..4d99f0bd41 100644 --- a/extra/tetris/gl/gl.factor +++ b/extra/tetris/gl/gl.factor @@ -22,7 +22,7 @@ IN: tetris.gl ! TODO: move implementation specific stuff into tetris-board : (draw-row) ( x y row -- ) - [ over ] dip nth dup + overd nth dup [ gl-color 2array draw-block ] [ 3drop ] if ; : draw-row ( y row -- ) diff --git a/extra/tokyo/assoc-functor/assoc-functor.factor b/extra/tokyo/assoc-functor/assoc-functor.factor index bfcba2e55b..1c4ff1b88a 100644 --- a/extra/tokyo/assoc-functor/assoc-functor.factor +++ b/extra/tokyo/assoc-functor/assoc-functor.factor @@ -39,7 +39,7 @@ M: TYPE assoc-size handle>> DBRNUM ; dup DBITERINIT drop 0 int [ 2dup DBITERNEXT dup ] [ [ memory>object ] [ tcfree ] bi - [ pick ] dip swap push + reach push ] while 3drop ; M: TYPE >alist diff --git a/extra/trees/avl/avl.factor b/extra/trees/avl/avl.factor index 7897b6dbe1..380898dae1 100644 --- a/extra/trees/avl/avl.factor +++ b/extra/trees/avl/avl.factor @@ -136,7 +136,7 @@ GENERIC: avl-delete ( key node -- node shorter? deleted? ) M: f avl-delete ( key f -- f f f ) nip f f ; : (avl-delete) ( key node -- node shorter? deleted? ) - swap over node-link avl-delete [ + tuck node-link avl-delete [ [ over set-node-link ] dip [ balance-delete ] [ f ] if ] dip ; diff --git a/extra/trees/trees.factor b/extra/trees/trees.factor index 905ed6d9f1..b9b00e2b47 100644 --- a/extra/trees/trees.factor +++ b/extra/trees/trees.factor @@ -320,7 +320,7 @@ DEFER: delete-node : (prune-extremity) ( parent node -- new-extremity ) dup node-link [ - [ nip ] dip (prune-extremity) + nipd (prune-extremity) ] [ [ delete-node swap set-node-link ] keep ] if* ; diff --git a/extra/ui/gadgets/charts/lines/lines.factor b/extra/ui/gadgets/charts/lines/lines.factor index fbdf080d63..0e5cc3f5a9 100644 --- a/extra/ui/gadgets/charts/lines/lines.factor +++ b/extra/ui/gadgets/charts/lines/lines.factor @@ -113,7 +113,7 @@ ALIAS: y second : calc-point-y ( slope y point -- xy ) over [ calc-x ] dip 2array ; : xyy>chunk ( x y1 y2 -- chunk ) - [ over ] dip 2array [ 2array ] dip 2array ; + overd 2array [ 2array ] dip 2array ; :: 2-point-chunk ( left right ymin ymax -- chunk ) left last :> left-point diff --git a/extra/webapps/fjsc/www/termlib/faq.html b/extra/webapps/fjsc/www/termlib/faq.html index 5adb516b07..92245e4412 100644 --- a/extra/webapps/fjsc/www/termlib/faq.html +++ b/extra/webapps/fjsc/www/termlib/faq.html @@ -1,356 +1,356 @@ - - - mass:werk termlib faq - - - - - - - - - - - - - - - - - - - -
termlib.js home|multiple terminal test|sample parser|faq|documentation
- - - - - - - - - - - - - - - - -
-

frequently asked questions

-

- -

-Can I add chrome to the terminal? (e.g. a window header, a close box)

- -Not by the means of the Terminal object's interface (since there are way too many things that you may possibly want to add).
-The Terminal object allows you to specify the background color, the frame color, the frame's width and the font class used. If you want to add more chrome, you must align this in a separate division element.

- -To calculate the dimensions of the terminal use this formula:

- -width:  2 * frameWidth + conf.cols * <width of  > + 2 * 2px padding (left and right)
-height: 2 * frameWidth + conf.rows * conf.rowHeight + 2 * 2px padding (top and bottom).

- -Or you could get the empirical values for width and height by calling a terminal's `getDimensions()' method, once the terminal is open. (see documentation in "readme.txt").

- -Finnally, you could obviously embed the terminal's division element in your custom chrome layout (see below). [This will not be compatible to Netscape 4.]

- -p.e.:
-  <div id="myTerminal1" style="position:absolute; top:100px; left:100px;">
-     <table class="termChrome">
-     	<tbody>
-        <tr>
-           <td class="termTitle">terminal 1</td>
-        </tr>
-        <tr>
-           <td class="termBody"><div id="termDiv1" style="position:relative"></div></td>
-        </tr>
-     	</tbody>
-     </table>
-   </div>
-
-   // get a terminal for this
-
-   var term1 = new Terminal(
-                 {
-                   x: 0,
-                   y: 0,
-                   id: 1,
-                   termDiv: "termDiv1",
-                   handler: myTermHandler
-                 }
-              );
-   term1.open();
-   
-   // and this is how to move the chrome and the embedded terminal
-
-   TermGlobals.setElementXY( "myTerminal1", 200, 80 );
-
-To keep track of the instance for any widgets use the terminal's `id' property. (You must set this in the configuration object to a unique value for this purpose.)

- -For a demonstration see the Chrome Sample Page. -

-How can I embed a terminal relative to my HTML layout?

- -Define your devision element with attribute "position" set to "relative" and place this inside your layout. Call "new Terminal()" with config-values { x: 0, y: 0 } to leave it at its relative origin. -

-I pasted your sample code and just got an error. - ???

- -The short examples are kept arbitrarily simple to show the syntax.
-Make sure that your divison element(s) is/are rendered by the browser before `Terminal.open()' is called.

- -Does not work: -
  <head>
-  <script>
-    var term = new Terminal();
-    term.open();
-  </script>
-  </head>
-
-Does work: -
  <head>
-  <script>
-    var term;
-    
-    function termOpen() {
-       // to be called from outside after compile time
-       term = new Terminal();
-       term.open();
-    }
-  </script>
-  </head>
-
-c.f. "readme.txt"
-(Opening a terminal by clicking a link implies also that the page has currently focus.)

-With v.1.01 and higher this doesn't cause an error any more.
`Terminal.prototype.open()' now returns a value for success. -

-I can't get any input, but I don't get any erros too.

- -The Terminal object's functionality relies on the browsers ability to generate and handle keyboard events.
-Sadly some browsers lack a full implementation of the event model. (e.g. Konquerer [khtml] and early versions of Apple Safari, which is a descendant of khtml.) -

-How can I temporary disable the keyboard handlers?
-(The terminal is blocking my HTML form fields, etc.)

- -With version 1.03 there's a global property `TermGlobals.keylock'. Set this to `true' to disable the keyboard handlers without altering any other state. Reset it to `false' to continue with your terminal session(s). -

-How can I set the cusor to the start / the end of the command line?

- -In case you need to implement a shortcut (like ^A of some UN*X-shells) to jump to the beginning or the end of the current input line, there are two private instance methods you could utilize:

-`_getLineEnd(<row>, <col>)' returns an array [<row>, <col>] with the position of the last character in the logical input line with ASCII value >= 32 (0x20).

-`_getLineStart(<row>, <col>)' returns an array [<row>, <col>] with the position of the first character in the logical input line with ASCII value >= 32 (0x20).

-Both take a row and a column of a cursor position as arguments.

- -p.e.: -
-  // jump to the start of the input line
-
-  myCtrlHandler() {
-     // catch ^A and jump to start of the line
-     if (this.inputChar == 1) {
-        var firstChar = this._getLineStart(this.r, this.c);
-        this.cursorSet(firstChar[0], firstChar[1]);
-     }
-  }
-(Keep in mind that this is not exactly a good example, since some browser actually don't issue a keyboard event for -"^A". And other browsers, which do catch such codes, are not very reliable in that.) -

-How can I limit the command history to unique entries only?
- (My application effords commands to be commonly repeated.)

- -With version 1.05 there is a new configuration and control flag `historyUnique'. All you need is setting this to `true' in your terminal's configuration object. -

-How can I change my color theme on the fly?

- -With version 1.07 there is a new method `Terminal.rebuild()'.
-This method updates the GUI to current config settings while preserving all other state.

-p.e.: -
-   // change color settings on the fly
-   // here: set bgColor to white and font style to class "termWhite"
-   // method rebuild() updates the GUI without side effects
-   // assume var term holds a referene to a Terminal object already active
-
-   term.conf.bgColor = '#ffffff';
-   term.conf.fontClass = 'termWhite';
-   term.rebuild();
-

-How can I connect to a server?

- -The Terminal object only provides an interface to handle console input and output.
-External connections have to be handled outside the Terminal object. You could use the XMLHttpRequest-Object (and use a communication model like AJAX or JSON) or connect via a frame or iframe element to a foreign host.

-Handling connections is considered to be out of the realm of the "termlib.js" library.
-The code you need is in fact quite simple: -
-  function connectToHost(url) {
-     if (window.XMLHttpRequest) {
-        request = new XMLHttpRequest();
-     }
-     else if (window.ActiveXObject) {
-         request = new ActiveXObject('Microsoft.XMLHTTP');
-     }
-     if (request) {
-         request.onreadystatechange = requestChangeHandler;
-         request.open('GET', url);
-         request.send('');
-     }
-     else {
-        // XMLHttpRequest not implemented
-     }
-  }
-  
-  function requestChangeHandler() {
-     if (request.readyState == 4) {
-        // readyState 4: complete; now test for server's response status
-        if (request.status == 200) {
-           // response in request.responseText or request.responseXML if XML-code
-           // if it's JS-code we could get this by eval(request.responseText)
-           // by this we could import whole functions to be used via the terminal
-        }
-        else {
-           // connection error
-           // status code and message in request.status and request.statusText
-        }
-     }
-  }
-
-You should use this only together with a timer (window.setTimeout()) to handle connection timeouts.
-Additionally you would need some syntax to authenticate and tell the server what you want.
-For this purpose you could use the following methods of the XMLHttpRequest object:

- - - - - - - -
setRequestHeader("headerLabel", "value")set a HTTP header to be sent to the server
getResponseHeader("headerLabel")get a HTTP header sent from the server
open(method, "url" [, asyncFlag [,
  "userid" [, "password"]]])
assign the destination properties to the request.
be aware that userid and password are not encrypted!
send(content)transmit a message body (post-string or DOM object)
abort()use this to stop a pending connection
- -
-  
- Norbert Landsteiner - August 2005
- http://www.masswerk.at -
-  
- > top of page -
-   -
- -
- - + + + mass:werk termlib faq + + + + + + + + + + + + + + + + + + + +
termlib.js home|multiple terminal test|sample parser|faq|documentation
+ + + + + + + + + + + + + + + + +
+

frequently asked questions

+

+ +

+Can I add chrome to the terminal? (e.g. a window header, a close box)

+ +Not by the means of the Terminal object's interface (since there are way too many things that you may possibly want to add).
+The Terminal object allows you to specify the background color, the frame color, the frame's width and the font class used. If you want to add more chrome, you must align this in a separate division element.

+ +To calculate the dimensions of the terminal use this formula:

+ +width:  2 * frameWidth + conf.cols * <width of  > + 2 * 2px padding (left and right)
+height: 2 * frameWidth + conf.rows * conf.rowHeight + 2 * 2px padding (top and bottom).

+ +Or you could get the empirical values for width and height by calling a terminal's `getDimensions()' method, once the terminal is open. (see documentation in "readme.txt").

+ +Finnally, you could obviously embed the terminal's division element in your custom chrome layout (see below). [This will not be compatible to Netscape 4.]

+ +p.e.:
+  <div id="myTerminal1" style="position:absolute; top:100px; left:100px;">
+     <table class="termChrome">
+     	<tbody>
+        <tr>
+           <td class="termTitle">terminal 1</td>
+        </tr>
+        <tr>
+           <td class="termBody"><div id="termDiv1" style="position:relative"></div></td>
+        </tr>
+     	</tbody>
+     </table>
+   </div>
+
+   // get a terminal for this
+
+   var term1 = new Terminal(
+                 {
+                   x: 0,
+                   y: 0,
+                   id: 1,
+                   termDiv: "termDiv1",
+                   handler: myTermHandler
+                 }
+              );
+   term1.open();
+   
+   // and this is how to move the chrome and the embedded terminal
+
+   TermGlobals.setElementXY( "myTerminal1", 200, 80 );
+
+To keep track of the instance for any widgets use the terminal's `id' property. (You must set this in the configuration object to a unique value for this purpose.)

+ +For a demonstration see the Chrome Sample Page. +

+How can I embed a terminal relative to my HTML layout?

+ +Define your devision element with attribute "position" set to "relative" and place this inside your layout. Call "new Terminal()" with config-values { x: 0, y: 0 } to leave it at its relative origin. +

+I pasted your sample code and just got an error. - ???

+ +The short examples are kept arbitrarily simple to show the syntax.
+Make sure that your divison element(s) is/are rendered by the browser before `Terminal.open()' is called.

+ +Does not work: +
  <head>
+  <script>
+    var term = new Terminal();
+    term.open();
+  </script>
+  </head>
+
+Does work: +
  <head>
+  <script>
+    var term;
+    
+    function termOpen() {
+       // to be called from outside after compile time
+       term = new Terminal();
+       term.open();
+    }
+  </script>
+  </head>
+
+c.f. "readme.txt"
+(Opening a terminal by clicking a link implies also that the page has currently focus.)

+With v.1.01 and higher this doesn't cause an error any more.
`Terminal.prototype.open()' now returns a value for success. +

+I can't get any input, but I don't get any erros too.

+ +The Terminal object's functionality relies on the browsers ability to generate and handle keyboard events.
+Sadly some browsers lack a full implementation of the event model. (e.g. Konquerer [khtml] and early versions of Apple Safari, which is a descendant of khtml.) +

+How can I temporary disable the keyboard handlers?
+(The terminal is blocking my HTML form fields, etc.)

+ +With version 1.03 there's a global property `TermGlobals.keylock'. Set this to `true' to disable the keyboard handlers without altering any other state. Reset it to `false' to continue with your terminal session(s). +

+How can I set the cusor to the start / the end of the command line?

+ +In case you need to implement a shortcut (like ^A of some UN*X-shells) to jump to the beginning or the end of the current input line, there are two private instance methods you could utilize:

+`_getLineEnd(<row>, <col>)' returns an array [<row>, <col>] with the position of the last character in the logical input line with ASCII value >= 32 (0x20).

+`_getLineStart(<row>, <col>)' returns an array [<row>, <col>] with the position of the first character in the logical input line with ASCII value >= 32 (0x20).

+Both take a row and a column of a cursor position as arguments.

+ +p.e.: +
+  // jump to the start of the input line
+
+  myCtrlHandler() {
+     // catch ^A and jump to start of the line
+     if (this.inputChar == 1) {
+        var firstChar = this._getLineStart(this.r, this.c);
+        this.cursorSet(firstChar[0], firstChar[1]);
+     }
+  }
+(Keep in mind that this is not exactly a good example, since some browser actually don't issue a keyboard event for +"^A". And other browsers, which do catch such codes, are not very reliable in that.) +

+How can I limit the command history to unique entries only?
+ (My application effords commands to be commonly repeated.)

+ +With version 1.05 there is a new configuration and control flag `historyUnique'. All you need is setting this to `true' in your terminal's configuration object. +

+How can I change my color theme on the fly?

+ +With version 1.07 there is a new method `Terminal.rebuild()'.
+This method updates the GUI to current config settings while preserving all other state.

+p.e.: +
+   // change color settings on the fly
+   // here: set bgColor to white and font style to class "termWhite"
+   // method rebuild() updates the GUI without side effects
+   // assume var term holds a referene to a Terminal object already active
+
+   term.conf.bgColor = '#ffffff';
+   term.conf.fontClass = 'termWhite';
+   term.rebuild();
+

+How can I connect to a server?

+ +The Terminal object only provides an interface to handle console input and output.
+External connections have to be handled outside the Terminal object. You could use the XMLHttpRequest-Object (and use a communication model like AJAX or JSON) or connect via a frame or iframe element to a foreign host.

+Handling connections is considered to be out of the realm of the "termlib.js" library.
+The code you need is in fact quite simple: +
+  function connectToHost(url) {
+     if (window.XMLHttpRequest) {
+        request = new XMLHttpRequest();
+     }
+     else if (window.ActiveXObject) {
+         request = new ActiveXObject('Microsoft.XMLHTTP');
+     }
+     if (request) {
+         request.onreadystatechange = requestChangeHandler;
+         request.open('GET', url);
+         request.send('');
+     }
+     else {
+        // XMLHttpRequest not implemented
+     }
+  }
+  
+  function requestChangeHandler() {
+     if (request.readyState == 4) {
+        // readyState 4: complete; now test for server's response status
+        if (request.status == 200) {
+           // response in request.responseText or request.responseXML if XML-code
+           // if it's JS-code we could get this by eval(request.responseText)
+           // by this we could import whole functions to be used via the terminal
+        }
+        else {
+           // connection error
+           // status code and message in request.status and request.statusText
+        }
+     }
+  }
+
+You should use this only together with a timer (window.setTimeout()) to handle connection timeouts.
+Additionally you would need some syntax to authenticate and tell the server what you want.
+For this purpose you could use the following methods of the XMLHttpRequest object:

+ + + + + + + +
setRequestHeader("headerLabel", "value")set a HTTP header to be sent to the server
getResponseHeader("headerLabel")get a HTTP header sent from the server
open(method, "url" [, asyncFlag [,
  "userid" [, "password"]]])
assign the destination properties to the request.
be aware that userid and password are not encrypted!
send(content)transmit a message body (post-string or DOM object)
abort()use this to stop a pending connection
+ +
+  
+ Norbert Landsteiner - August 2005
+ http://www.masswerk.at +
+  
+ > top of page +
+   +
+ +
+ + \ No newline at end of file diff --git a/extra/webapps/fjsc/www/termlib/index.html b/extra/webapps/fjsc/www/termlib/index.html index 1770b2ca13..f38f6e1580 100644 --- a/extra/webapps/fjsc/www/termlib/index.html +++ b/extra/webapps/fjsc/www/termlib/index.html @@ -1,207 +1,207 @@ - - - mass:werk termlib - - - - - - - - - - - - - - - - - - - -
termlib.js home|multiple terminal test|sample parser|faq|documentation
- - - - - - - - - - - - - -
-

mass:werk termlib.js

-
- The JavaScript library "termlib.js" provides a `Terminal' object, which - facillitates a simple and object oriented approach to generate and control a - terminal-like interface for web services.

- - "termlib.js" features direct keyboard input and powerful output methods - for multiple and simultanious instances of the `Terminal' object.

- - The library was written with the aim of simple usage and a maximum of compatibility - with minimal foot print in the global namespace.


- - - A short example:
-
-  var term = new Terminal( {handler: termHandler} );
-  term.open();
-
-  function termHandler() {
-     this.newLine();
-     var line = this.lineBuffer;
-     if (line != "") {
-        this.write("You typed: "+line);
-     }
-     this.prompt();
-  }
-  
-
- License

- - This JavaScript-library is free for private and academic use. - Please include a readable copyright statement and a backlink to <http://www.masswerk.at> in the - web page. The library should always be accompanied by the "readme.txt" and the sample HTML-documents.

- - The term "private use" includes any personal or non-commercial use, which is not related - to commercial activites, but excludes intranet, extranet and/or public net applications - that are related to any kind of commercial or profit oriented activity.

- - For commercial use see <http://www.masswerk.at> for contact information. -
- Distribution

- - This JavaScript-library may be distributed freely as long it is distributed together with the "readme.txt" and the sample HTML-documents and this document.

- - Any changes to the library should be commented and be documented in the readme-file.
- Any changes must be reflected in the `Terminal.version' string as "Version.Subversion (compatibility)". -
- Disclaimer

- - This software is distributed AS IS and in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. The entire risk as to the quality and performance of the product is borne by the - user. No use of the product is authorized hereunder except under this disclaimer. -
- History

- - This library evolved from the terminal script "TermApp" ((c) N. Landsteiner 2003) and is in its - current form a down scaled spinn-off of the "JS/UIX" project. (JS/UIX is not a free software by now.) - c.f.: <http://www.masswerk.at/jsuix>

- - For version history: see the readme.txt. -
-  
- Download

- Be sure to have read the license information and the disclamer and that you are willing to respect copyrights.

- - Download: termlib.zip (~ 40 KB, incl. docs)

- Current version is "1.07 (original)".
- The files are now provided with line breaks in format <CRLF>.
-   -
- Author

- © Norbert Landsteiner 2003-2005
- mass:werk – media environments
- http://www.masswerk.at -
-  
- Author's note:
- Please do not contact me on questions of simple usage. There is an extensive documentation (readme.txt) including plenty of sample code that should provide all information you need. -
-  
- > top of page -
-   -
- -
- - + + + mass:werk termlib + + + + + + + + + + + + + + + + + + + +
termlib.js home|multiple terminal test|sample parser|faq|documentation
+ + + + + + + + + + + + + +
+

mass:werk termlib.js

+
+ The JavaScript library "termlib.js" provides a `Terminal' object, which + facillitates a simple and object oriented approach to generate and control a + terminal-like interface for web services.

+ + "termlib.js" features direct keyboard input and powerful output methods + for multiple and simultanious instances of the `Terminal' object.

+ + The library was written with the aim of simple usage and a maximum of compatibility + with minimal foot print in the global namespace.


+ + + A short example:
+
+  var term = new Terminal( {handler: termHandler} );
+  term.open();
+
+  function termHandler() {
+     this.newLine();
+     var line = this.lineBuffer;
+     if (line != "") {
+        this.write("You typed: "+line);
+     }
+     this.prompt();
+  }
+  
+
+ License

+ + This JavaScript-library is free for private and academic use. + Please include a readable copyright statement and a backlink to <http://www.masswerk.at> in the + web page. The library should always be accompanied by the "readme.txt" and the sample HTML-documents.

+ + The term "private use" includes any personal or non-commercial use, which is not related + to commercial activites, but excludes intranet, extranet and/or public net applications + that are related to any kind of commercial or profit oriented activity.

+ + For commercial use see <http://www.masswerk.at> for contact information. +
+ Distribution

+ + This JavaScript-library may be distributed freely as long it is distributed together with the "readme.txt" and the sample HTML-documents and this document.

+ + Any changes to the library should be commented and be documented in the readme-file.
+ Any changes must be reflected in the `Terminal.version' string as "Version.Subversion (compatibility)". +
+ Disclaimer

+ + This software is distributed AS IS and in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. The entire risk as to the quality and performance of the product is borne by the + user. No use of the product is authorized hereunder except under this disclaimer. +
+ History

+ + This library evolved from the terminal script "TermApp" ((c) N. Landsteiner 2003) and is in its + current form a down scaled spinn-off of the "JS/UIX" project. (JS/UIX is not a free software by now.) + c.f.: <http://www.masswerk.at/jsuix>

+ + For version history: see the readme.txt. +
+  
+ Download

+ Be sure to have read the license information and the disclamer and that you are willing to respect copyrights.

+ + Download: termlib.zip (~ 40 KB, incl. docs)

+ Current version is "1.07 (original)".
+ The files are now provided with line breaks in format <CRLF>.
+   +
+ Author

+ © Norbert Landsteiner 2003-2005
+ mass:werk – media environments
+ http://www.masswerk.at +
+  
+ Author's note:
+ Please do not contact me on questions of simple usage. There is an extensive documentation (readme.txt) including plenty of sample code that should provide all information you need. +
+  
+ > top of page +
+   +
+ +
+ + \ No newline at end of file diff --git a/extra/webapps/fjsc/www/termlib/multiterm_test.html b/extra/webapps/fjsc/www/termlib/multiterm_test.html index 0a4e1ec63a..23aaaefb72 100644 --- a/extra/webapps/fjsc/www/termlib/multiterm_test.html +++ b/extra/webapps/fjsc/www/termlib/multiterm_test.html @@ -1,188 +1,188 @@ - - - termlib Multiple Terminal Test - - - - - - - - - - - - - - - - - - - - - - -
termlib.js home|multiple terminal test|sample parser|faq|documentation
- - - - - - -
- Multiple Terminal Test
  -
- > open terminal 1   -
- > open terminal 2   -
-  
- (c) mass:werk,
N. Landsteiner 2003-2005
- http://www.masswerk.at -
- -
-
- - + + + termlib Multiple Terminal Test + + + + + + + + + + + + + + + + + + + + + + +
termlib.js home|multiple terminal test|sample parser|faq|documentation
+ + + + + + +
+ Multiple Terminal Test
  +
+ > open terminal 1   +
+ > open terminal 2   +
+  
+ (c) mass:werk,
N. Landsteiner 2003-2005
+ http://www.masswerk.at +
+ +
+
+ + \ No newline at end of file diff --git a/extra/webapps/fjsc/www/termlib/parser_sample.html b/extra/webapps/fjsc/www/termlib/parser_sample.html index b332af1818..41b4c5ef62 100644 --- a/extra/webapps/fjsc/www/termlib/parser_sample.html +++ b/extra/webapps/fjsc/www/termlib/parser_sample.html @@ -1,293 +1,293 @@ - - - termlib Sample Parser - - - - - - - - - - - - - - - - - - - - - - - -
termlib.js home|multiple terminal test|sample parser|faq|documentation
- - - - - - -
- Sample Parser Test
  -
- > open terminal   -
-   -
-  
- (c) mass:werk,
N. Landsteiner 2003-2005
- http://www.masswerk.at -
- -
- - + + + termlib Sample Parser + + + + + + + + + + + + + + + + + + + + + + + +
termlib.js home|multiple terminal test|sample parser|faq|documentation
+ + + + + + +
+ Sample Parser Test
  +
+ > open terminal   +
+   +
+  
+ (c) mass:werk,
N. Landsteiner 2003-2005
+ http://www.masswerk.at +
+ +
+ + \ No newline at end of file diff --git a/extra/zeromq/examples/taskvent.factor b/extra/zeromq/examples/taskvent.factor index e462935950..0532b8c25c 100644 --- a/extra/zeromq/examples/taskvent.factor +++ b/extra/zeromq/examples/taskvent.factor @@ -30,7 +30,7 @@ IN: zeromq.examples.taskvent ! Random workload from 1 to 100msecs 100 random 1 + dup [ + ] dip - [ pick ] dip "%d" sprintf >byte-array 0 zmq-send + pickd "%d" sprintf >byte-array 0 zmq-send ] times "Total expected cost: %d msec\n" printf diff --git a/misc/vim/syntax/factor.vim b/misc/vim/syntax/factor.vim index 704cf706eb..8854715036 100644 --- a/misc/vim/syntax/factor.vim +++ b/misc/vim/syntax/factor.vim @@ -53,7 +53,7 @@ syn match factorCallQuotation /\/ con syn match factorExecute /\/ contained contains=factorStackEffect syn keyword factorCallNextMethod call-next-method -syn keyword factorKeyword (clone) -rot 2bi 2bi* 2bi@ 2curry 2dip 2drop 2dup 2keep 2nip 2over 2tri 2tri* 2tri@ 2with 3bi 3curry 3dip 3drop 3dup 3keep 3tri 4dip 4drop 4dup 4keep = >boolean ? ?if and assert assert= assert? bi bi* bi-curry bi-curry* bi-curry@ bi@ boa boolean boolean? both? build call callstack callstack>array callstack? clear clone compose composed composed? curried curried? curry die dip do drop dup dupd either? eq? equal? execute get-callstack get-datastack get-retainstack hashcode hashcode* identity-hashcode identity-tuple identity-tuple? if if* keep loop most new nip not null object or over pick prepose rot same? swap swapd throw tri tri* tri-curry tri-curry* tri-curry@ tri@ tuple tuple? unless unless* until when when* while with wrapper wrapper? xor +syn keyword factorKeyword (clone) -roll -rot -rotd 2bi 2bi* 2bi@ 2curry 2dip 2drop 2dup 2keep 2keepd 2nip 2nipd 2over 2tri 2tri* 2tri@ 2with 3bi 3curry 3dip 3drop 3dup 3keep 3nip 3nipd 3tri 4dip 4drop 4dup 4keep 4nip 5drop 5nip = >boolean ? ?if and assert assert= assert? bi bi* bi-curry bi-curry* bi-curry@ bi@ boa boolean boolean? both? build call callstack callstack>array callstack? clear clone compose composed composed? curried curried? curry die dip do drop dup dupd either? eq? equal? execute get-callstack get-datastack get-retainstack hashcode hashcode* identity-hashcode identity-tuple identity-tuple? if if* keep keepd keepdd loop most new nip nipd not null object or over overd pick pickd prepose reach roll rot rotd same? spin swap swapd throw tri tri* tri-curry tri-curry* tri-curry@ tri@ tuck tuple tuple? unless unless* until when when* while with wrapper wrapper? xor syn keyword factorKeyword 2cache >alist ?at ?of assoc assoc-all? assoc-any? assoc-clone-like assoc-combine assoc-diff assoc-diff! assoc-differ assoc-each assoc-empty? assoc-filter assoc-filter! assoc-filter-as assoc-find assoc-hashcode assoc-intersect assoc-like assoc-map assoc-map-as assoc-partition assoc-refine assoc-reject assoc-reject! assoc-reject-as assoc-size assoc-stack assoc-subset? assoc-union assoc-union! assoc-union-as assoc= assoc>map assoc? at at* at+ cache change-at clear-assoc collect-by delete-at delete-at* enumerated enumerated? extract-keys harvest-keys harvest-values inc-at key? keys map>alist map>assoc maybe-set-at new-assoc of push-at rename-at set-at sift-keys sift-values substitute unzip value-at value-at* value? values zip zip-as zip-index zip-index-as syn keyword factorKeyword 2cleave 2cleave>quot 3cleave 3cleave>quot 4cleave 4cleave>quot alist>quot call-effect case case-find case>quot cleave cleave>quot cond cond>quot deep-spread>quot execute-effect linear-case-quot no-case no-case? no-cond no-cond? recursive-hashcode shallow-spread>quot spread to-fixed-point wrong-values wrong-values? syn keyword factorKeyword (all-integers?) (each-integer) (find-integer) * + - / /f /i /mod 2/ 2^ < <= > >= >bignum >fixnum >float >fraction >integer >rect ?1+ abs align all-integers? bignum bignum? bit? bitand bitnot bitor bits>double bits>float bitxor complex complex? denominator double>bits each-integer even? find-integer find-last-integer fixnum fixnum? float float>bits float? fp-bitwise= fp-infinity? fp-nan-payload fp-nan? fp-qnan? fp-sign fp-snan? fp-special? gcd if-zero imaginary-part integer integer>fixnum integer>fixnum-strict integer? log2 log2-expects-positive log2-expects-positive? mod neg neg? next-float next-power-of-2 number number= number? numerator odd? power-of-2? prev-float ratio ratio? rational rational? real real-part real? recip rect> rem sgn shift simple-gcd sq times u< u<= u> u>= unless-zero unordered? when-zero zero?