From 1a73e79ef7e9c479a9ba04df7f1dd5212238b65d Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Thu, 19 Jul 2012 13:55:34 -0700 Subject: [PATCH] cleanup some use of with-scope. --- basis/classes/struct/struct-tests.factor | 22 ++++++---------- basis/help/html/html.factor | 13 +++++----- basis/help/markup/markup-tests.factor | 3 ++- .../dispatchers/dispatchers-tests.factor | 26 +++++++++---------- basis/io/backend/unix/unix-tests.factor | 9 +++---- basis/io/files/info/unix/linux/linux.factor | 5 +--- .../matrices/elimination/elimination.factor | 2 +- basis/nmake/nmake.factor | 2 +- basis/pack/pack-tests.factor | 4 +-- basis/prettyprint/sections/sections.factor | 11 ++++---- basis/refs/refs-tests.factor | 2 +- basis/threads/threads-tests.factor | 5 ++-- basis/ui/render/render.factor | 2 +- extra/asn1/asn1.factor | 5 +--- extra/game/models/obj/obj.factor | 2 +- extra/model-viewer/model-viewer.factor | 4 +-- extra/opencl/opencl.factor | 4 +-- 17 files changed, 52 insertions(+), 69 deletions(-) diff --git a/basis/classes/struct/struct-tests.factor b/basis/classes/struct/struct-tests.factor index b619c5abcd..45373a96ac 100644 --- a/basis/classes/struct/struct-tests.factor +++ b/basis/classes/struct/struct-tests.factor @@ -161,36 +161,30 @@ STRUCT: struct-test-string-ptr [ "S{ struct-test-foo { x 0 } { y 7654 } { z f } }" ] [ - [ - boa-tuples? off - c-object-pointers? off + H{ { boa-tuples? f } { c-object-pointers? f } } [ struct-test-foo 7654 >>y [ pprint ] with-string-writer - ] with-scope + ] with-variables ] unit-test [ "S@ struct-test-foo B{ 0 0 0 0 0 0 0 0 0 0 0 0 }" ] [ - [ - c-object-pointers? on + H{ { c-object-pointers? t } } [ 12 struct-test-foo memory>struct [ pprint ] with-string-writer - ] with-scope + ] with-variables ] unit-test [ "S{ struct-test-foo f 0 7654 f }" ] [ - [ - boa-tuples? on - c-object-pointers? off + H{ { boa-tuples? t } { c-object-pointers? f } } [ struct-test-foo 7654 >>y [ pprint ] with-string-writer - ] with-scope + ] with-variables ] unit-test [ "S@ struct-test-foo f" ] [ - [ - c-object-pointers? off + H{ { c-object-pointers? f } } [ f struct-test-foo memory>struct [ pprint ] with-string-writer - ] with-scope + ] with-variables ] unit-test [ "USING: alien.c-types classes.struct ; diff --git a/basis/help/html/html.factor b/basis/help/html/html.factor index e4a3031949..53b75bc44c 100644 --- a/basis/help/html/html.factor +++ b/basis/help/html/html.factor @@ -118,13 +118,12 @@ M: topic url-of topic>filename ; all-topics [ '[ _ generate-help-file ] try ] each ; : generate-help-files ( -- ) - [ - recent-searches off - recent-words off - recent-articles off - recent-vocabs off - (generate-help-files) - ] with-scope ; + H{ + { recent-searches f } + { recent-words f } + { recent-articles f } + { recent-vocabs f } + } [ (generate-help-files) ] with-variables ; : generate-help ( -- ) "docs" cache-file diff --git a/basis/help/markup/markup-tests.factor b/basis/help/markup/markup-tests.factor index 4a89e98dc6..658f7c98cd 100644 --- a/basis/help/markup/markup-tests.factor +++ b/basis/help/markup/markup-tests.factor @@ -5,7 +5,8 @@ FROM: namespaces => set ; IN: help.markup.tests : with-markup-test ( quot -- ) - '[ f last-element set _ with-string-writer ] with-scope ; inline + [ f last-element ] dip + '[ _ with-string-writer ] with-variable ; inline TUPLE: blahblah quux ; diff --git a/basis/http/server/dispatchers/dispatchers-tests.factor b/basis/http/server/dispatchers/dispatchers-tests.factor index 08974aca3b..da4c4c78ec 100644 --- a/basis/http/server/dispatchers/dispatchers-tests.factor +++ b/basis/http/server/dispatchers/dispatchers-tests.factor @@ -19,15 +19,14 @@ M: mock-responder call-responder* main-responder get call-responder write-response get ; -[ + + "foo" "foo" add-responder + "bar" "bar" add-responder - "foo" "foo" add-responder - "bar" "bar" add-responder - - "123" "123" add-responder - "default" >>default - "baz" add-responder - main-responder set + "123" "123" add-responder + "default" >>default + "baz" add-responder +main-responder [ [ "foo" ] [ { "foo" } main-responder get find-responder path>> nip @@ -46,15 +45,14 @@ M: mock-responder call-responder* [ t ] [ "123" "baz/123" check-dispatch ] unit-test [ t ] [ "123" "baz///123" check-dispatch ] unit-test -] with-scope +] with-variable -[ - - "default" >>default - main-responder set + + "default" >>default +main-responder [ [ "/default" ] [ "/default" main-responder get find-responder drop ] unit-test -] with-scope +] with-variable ! Make sure path for default responder isn't chopped TUPLE: path-check-responder ; diff --git a/basis/io/backend/unix/unix-tests.factor b/basis/io/backend/unix/unix-tests.factor index 6eb4227855..caf4c3691a 100644 --- a/basis/io/backend/unix/unix-tests.factor +++ b/basis/io/backend/unix/unix-tests.factor @@ -41,13 +41,12 @@ yield [ datagram-client delete-file ] ignore-errors [ - [ - datagram-server "d" set + datagram-server "d" [ "Receive 1" print "d" get receive [ reverse ] dip - + "Send 1" print dup . @@ -56,7 +55,7 @@ yield "Receive 2" print "d" get receive [ " world" append ] dip - + "Send 1" print dup . @@ -67,7 +66,7 @@ yield "Done" print datagram-server delete-file - ] with-scope + ] with-variable ] "Test" spawn drop yield diff --git a/basis/io/files/info/unix/linux/linux.factor b/basis/io/files/info/unix/linux/linux.factor index 9823011045..cb5d0114af 100644 --- a/basis/io/files/info/unix/linux/linux.factor +++ b/basis/io/files/info/unix/linux/linux.factor @@ -56,10 +56,7 @@ frequency pass-number ; } cleave ; : parse-mtab ( -- array ) - [ - "/etc/mtab" utf8 - CHAR: \s delimiter set csv - ] with-scope + CHAR: \s [ "/etc/mtab" utf8 file>csv ] with-delimiter [ mtab-csv>mtab-entry ] map ; M: linux file-systems diff --git a/basis/math/matrices/elimination/elimination.factor b/basis/math/matrices/elimination/elimination.factor index 6dfcf9f0ca..c3beb6b0dd 100644 --- a/basis/math/matrices/elimination/elimination.factor +++ b/basis/math/matrices/elimination/elimination.factor @@ -7,7 +7,7 @@ IN: math.matrices.elimination SYMBOL: matrix : with-matrix ( matrix quot -- ) - [ swap matrix set call matrix get ] with-scope ; inline + matrix swap [ matrix get ] compose with-variable ; inline : nth-row ( row# -- seq ) matrix get nth ; diff --git a/basis/nmake/nmake.factor b/basis/nmake/nmake.factor index 912bb17218..b4dc3871d4 100644 --- a/basis/nmake/nmake.factor +++ b/basis/nmake/nmake.factor @@ -4,7 +4,7 @@ USING: namespaces sequences math.parser kernel macros generalizations sequences.generalizations locals ; IN: nmake -SYMBOL: building-seq +SYMBOL: building-seq : get-building-seq ( n -- seq ) building-seq get nth ; diff --git a/basis/pack/pack-tests.factor b/basis/pack/pack-tests.factor index 999a952174..440d6a0369 100644 --- a/basis/pack/pack-tests.factor +++ b/basis/pack/pack-tests.factor @@ -13,9 +13,7 @@ IN: pack.tests ] unit-test [ B{ 1 2 0 3 0 0 4 0 0 0 5 0 0 0 0 0 0 0 } ] [ - [ - { 1 2 3 4 5 } "cstiq" pack-le - ] with-scope + { 1 2 3 4 5 } "cstiq" pack-le ] unit-test [ { 1 2 3 4 5 } ] [ diff --git a/basis/prettyprint/sections/sections.factor b/basis/prettyprint/sections/sections.factor index e9aae02c33..e38a65135f 100644 --- a/basis/prettyprint/sections/sections.factor +++ b/basis/prettyprint/sections/sections.factor @@ -354,15 +354,16 @@ M: block long-section ( block -- ) : make-pprint ( obj quot -- block manifest ) [ - 0 position set - H{ } clone pprinter-use set - V{ } clone recursion-check set - V{ } clone pprinter-stack set + 0 position ,, + H{ } clone pprinter-use ,, + V{ } clone recursion-check ,, + V{ } clone pprinter-stack ,, + ] H{ } make [ over [ take ] keep get-ref ] unit-test [ lion ] [ rabbit dup [ drop lion ] change-ref get-ref ] unit-test -! var-refs +! var-refs [ giraffe ] [ [ giraffe rabbit set rabbit get-ref ] with-scope ] unit-test [ rabbit ] diff --git a/basis/threads/threads-tests.factor b/basis/threads/threads-tests.factor index 35ffb3e4c3..e5812c3fc1 100644 --- a/basis/threads/threads-tests.factor +++ b/basis/threads/threads-tests.factor @@ -29,10 +29,9 @@ yield :: spawn-namespace-test ( -- ? ) :> p gensym :> g - [ - g "x" set + g "x" [ [ "x" get p fulfill ] "B" spawn drop - ] with-scope + ] with-variable p ?promise g eq? ; [ t ] [ spawn-namespace-test ] unit-test diff --git a/basis/ui/render/render.factor b/basis/ui/render/render.factor index 84edbc35c3..872c50f6eb 100644 --- a/basis/ui/render/render.factor +++ b/basis/ui/render/render.factor @@ -136,7 +136,7 @@ M: gadget draw-children [ gadget-background ] [ gadget-foreground ] } cleave [ - + { [ [ selected-gadgets set ] when* ] [ [ selection-background set ] when* ] diff --git a/extra/asn1/asn1.factor b/extra/asn1/asn1.factor index 14fc02f882..ac43c94d0a 100644 --- a/extra/asn1/asn1.factor +++ b/extra/asn1/asn1.factor @@ -193,10 +193,7 @@ TUPLE: tag value ; : ( -- ) 4 tag boa ; : with-ber ( quot -- ) - [ - tagnum set - call - ] with-scope ; inline + [ tagnum ] dip with-variable ; inline : set-tag ( value -- ) tagnum get value<< ; diff --git a/extra/game/models/obj/obj.factor b/extra/game/models/obj/obj.factor index 1bfe01c920..eef576d419 100644 --- a/extra/game/models/obj/obj.factor +++ b/extra/game/models/obj/obj.factor @@ -4,7 +4,7 @@ USING: io io.encodings.ascii math.parser sequences splitting kernel assocs io.files combinators math.order math namespaces arrays sequences.deep accessors alien.c-types alien.data game.models game.models.util gpu.shaders images game.models.loader -prettyprint specialized-arrays ; +prettyprint specialized-arrays make ; QUALIFIED-WITH: alien.c-types c SPECIALIZED-ARRAYS: c:float c:uint ; IN: game.models.obj diff --git a/extra/model-viewer/model-viewer.factor b/extra/model-viewer/model-viewer.factor index 72d603540d..ef1308d972 100644 --- a/extra/model-viewer/model-viewer.factor +++ b/extra/model-viewer/model-viewer.factor @@ -100,7 +100,7 @@ TUPLE: vbo BGR >>component-order ubyte-components >>component-type B{ 0 0 0 } >>bitmap ; - + : make-texture ( pathname alt -- texture ) swap [ nip load-image ] [ ] if* [ @@ -115,7 +115,7 @@ TUPLE: vbo [ 0 swap [ allocate-texture-image ] 3keep 2drop ] bi ; - + : ( models -- buffers ) [ { diff --git a/extra/opencl/opencl.factor b/extra/opencl/opencl.factor index a5753fe427..e1c105959d 100644 --- a/extra/opencl/opencl.factor +++ b/extra/opencl/opencl.factor @@ -2,8 +2,8 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien alien.c-types alien.data arrays byte-arrays combinators combinators.smart destructors -io.encodings.ascii io.encodings.string kernel libc locals math -namespaces opencl.ffi sequences shuffle specialized-arrays +io.encodings.ascii io.encodings.string kernel libc locals make +math namespaces opencl.ffi sequences shuffle specialized-arrays variants ; IN: opencl SPECIALIZED-ARRAYS: void* char size_t ; -- 2.34.1