]> gitweb.factorcode.org Git - factor.git/commitdiff
combinators.extras: make a with-variable for global, and with-output-global-variable
authorDoug Coleman <doug.coleman@gmail.com>
Thu, 11 Jan 2024 14:54:57 +0000 (08:54 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Thu, 11 Jan 2024 14:54:57 +0000 (08:54 -0600)
extra/combinators/extras/extras.factor

index d6362e86f11cb29eb3cecf676b1734d100b595bc..f2fb2fe1bc8fa206cdf3a9e98604cdd6a6605d19 100644 (file)
@@ -172,6 +172,12 @@ MACRO: chain ( quots -- quot )
 : with-output-variable ( value variable quot -- value )
     over '[ @ _ get ] with-variable ; inline
 
+: with-global-variable ( value key quot -- )
+    [ set-global ] dip call ; inline
+
+: with-output-global-variable ( value variable quot -- value )
+    over '[ @ _ get-global ] with-global-variable ; inline
+
 : loop1 ( ..a quot: ( ..a -- ..a obj ? ) -- ..a obj )
     [ call ] keep '[ drop _ loop1 ] when ; inline recursive