]> gitweb.factorcode.org Git - factor.git/commitdiff
Fixing everything for mandatory stack effects
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Mon, 9 Jun 2008 07:14:14 +0000 (02:14 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Mon, 9 Jun 2008 07:14:14 +0000 (02:14 -0500)
133 files changed:
core/bootstrap/primitives.factor
core/classes/classes.factor
core/classes/mixin/mixin.factor
core/classes/tuple/tuple.factor
core/classes/union/union.factor
core/compiler/tests/redefine.factor [new file with mode: 0644]
core/compiler/tests/simple.factor
core/compiler/units/units.factor
core/definitions/definitions.factor
core/effects/effects-docs.factor
core/effects/effects-tests.factor
core/generic/generic.factor
core/inference/backend/backend-docs.factor
core/inference/errors/errors.factor
core/inference/inference-docs.factor
core/inference/state/state-tests.factor
core/inference/state/state.factor
core/inference/transforms/transforms-tests.factor
core/inference/transforms/transforms.factor
core/optimizer/inlining/inlining.factor
core/parser/parser.factor
core/prettyprint/prettyprint-tests.factor
core/quotations/quotations.factor
core/slots/slots-docs.factor
core/syntax/syntax-docs.factor
core/words/words.factor
extra/asn1/asn1.factor
extra/benchmark/continuations/continuations.factor
extra/benchmark/dispatch2/dispatch2.factor
extra/benchmark/dispatch3/dispatch3.factor
extra/benchmark/dispatch4/dispatch4.factor
extra/benchmark/fasta/fasta.factor
extra/benchmark/fib1/fib1.factor
extra/benchmark/fib2/fib2.factor
extra/benchmark/fib3/fib3.factor
extra/benchmark/fib4/fib4.factor
extra/benchmark/fib5/fib5.factor
extra/benchmark/fib6/fib6.factor
extra/benchmark/iteration/iteration.factor
extra/benchmark/mandel/mandel.factor
extra/benchmark/nsieve-bits/nsieve-bits.factor
extra/benchmark/nsieve/nsieve.factor
extra/benchmark/partial-sums/partial-sums.factor
extra/benchmark/random/random.factor
extra/benchmark/raytracer/raytracer.factor
extra/benchmark/recursive/recursive.factor
extra/benchmark/reverse-complement/reverse-complement.factor
extra/benchmark/sockets/sockets.factor
extra/benchmark/sort/sort.factor
extra/benchmark/typecheck1/typecheck1.factor
extra/benchmark/typecheck2/typecheck2.factor
extra/benchmark/typecheck3/typecheck3.factor
extra/benchmark/typecheck4/typecheck4.factor
extra/bitfields/bitfields.factor
extra/bootstrap/image/upload/upload.factor
extra/bunny/model/model.factor
extra/calendar/format/format.factor
extra/checksums/md5/md5.factor
extra/cpu/8080/emulator/emulator.factor
extra/db/postgresql/ffi/ffi.factor
extra/db/postgresql/lib/lib.factor
extra/db/sql/sql.factor
extra/furnace/auth/providers/db/db.factor
extra/furnace/boilerplate/boilerplate.factor
extra/furnace/furnace.factor
extra/furnace/sessions/sessions.factor
extra/geo-ip/geo-ip.factor
extra/globs/globs.factor
extra/hardware-info/windows/nt/nt.factor
extra/hello-world/hello-world.factor
extra/help/cookbook/cookbook.factor
extra/help/help.factor
extra/help/syntax/syntax.factor
extra/html/components/components.factor
extra/html/elements/elements.factor
extra/html/streams/streams.factor
extra/http/http.factor
extra/http/server/cgi/cgi.factor
extra/koszul/koszul.factor
extra/lists/lazy/examples/examples.factor
extra/logging/analysis/analysis.factor
extra/logging/logging.factor
extra/logging/parser/parser.factor
extra/logging/server/server.factor
extra/math/matrices/elimination/elimination.factor
extra/math/matrices/matrices.factor
extra/math/polynomials/polynomials.factor
extra/minneapolis-talk/minneapolis-talk.factor
extra/monads/monads.factor
extra/multi-methods/multi-methods.factor
extra/namespaces/lib/lib.factor
extra/nehe/nehe.factor
extra/numbers-game/numbers-game.factor
extra/openal/openal.factor
extra/optimizer/report/report.factor
extra/present/present.factor
extra/regexp/regexp.factor
extra/regexp2/regexp2-tests.factor [deleted file]
extra/regexp2/regexp2.factor [deleted file]
extra/reports/noise/noise.factor
extra/slides/slides.factor
extra/smtp/smtp.factor
extra/state-machine/state-machine.factor
extra/state-parser/state-parser.factor
extra/sudoku/sudoku.factor
extra/taxes/taxes.factor
extra/tools/deploy/test/1/1.factor
extra/tools/deploy/test/2/2.factor
extra/tools/deploy/test/3/3.factor
extra/trees/splay/splay.factor
extra/tty-server/tty-server.factor
extra/turing/turing.factor
extra/units/si/si.factor
extra/units/units.factor
extra/vars/vars.factor
extra/webapps/blogs/blogs.factor
extra/webapps/factor-website/factor-website.factor
extra/webapps/pastebin/pastebin.factor
extra/webapps/planet/planet.factor
extra/webapps/todo/todo.factor
extra/webapps/wiki/wiki.factor
extra/windows/advapi32/advapi32.factor
extra/windows/kernel32/kernel32.factor
extra/windows/windows.factor
extra/x11/clipboard/clipboard.factor
extra/x11/constants/constants.factor
extra/x11/xlib/xlib.factor
extra/xml/errors/errors.factor
extra/xmode/keyword-map/keyword-map.factor
extra/xmode/loader/loader.factor
extra/xmode/loader/syntax/syntax.factor
extra/xmode/marker/marker.factor
extra/xmode/utilities/utilities.factor

index 6fc8ca768557d351f3609626fb61ad47903e697f..6a3c1c35d5659b15eaa6c4e6dcf515dcb7c80312 100755 (executable)
@@ -31,6 +31,7 @@ crossref off
 ! Bring up a bare cross-compiling vocabulary.
 "syntax" vocab vocab-words bootstrap-syntax set
 H{ } clone dictionary set
+H{ } clone new-classes set
 H{ } clone changed-definitions set
 H{ } clone forgotten-definitions set
 H{ } clone root-cache set
index 91fc4c60a739583f81e25649296360fa9a5bc5be..593213c5c637e9912155939e9d754172f267f9fa 100755 (executable)
@@ -67,8 +67,6 @@ GENERIC: reset-class ( class -- )
 
 M: word reset-class drop ;
 
-<PRIVATE
-
 ! update-map
 : class-uses ( class -- seq )
     [
@@ -81,6 +79,8 @@ M: word reset-class drop ;
 : class-usages ( class -- assoc )
     [ update-map get at ] closure ;
 
+<PRIVATE
+
 : update-map+ ( class -- )
     dup class-uses update-map get add-vertex ;
 
@@ -100,6 +100,7 @@ M: word reset-class drop ;
 : (define-class) ( word props -- )
     >r
     dup reset-class
+    dup class? [ dup new-class ] unless
     dup deferred? [ dup define-symbol ] when
     dup word-props
     r> assoc-union over set-word-props
@@ -115,13 +116,13 @@ GENERIC: update-class ( class -- )
 
 M: class update-class drop ;
 
-GENERIC: update-methods ( assoc -- )
+GENERIC: update-methods ( class assoc -- )
 
 : update-classes ( class -- )
-    class-usages
-    [ [ drop update-class ] assoc-each ]
+    dup class-usages
+    [ nip keys [ update-class ] each ]
     [ update-methods ]
-    bi ;
+    2bi ;
 
 : define-class ( word superclass members participants metaclass -- )
     #! If it was already a class, update methods after.
index 6f888ceca167a6b91751ffb1a23f5757f55361a8..4f4f2e10e1bc193fceb0c684167163033281dfd2 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: classes classes.union words kernel sequences
-definitions combinators arrays accessors ;
+definitions combinators arrays assocs generic accessors ;
 IN: classes.mixin
 
 PREDICATE: mixin-class < union-class "mixin" word-prop ;
@@ -12,8 +12,9 @@ M: mixin-class reset-class
 M: mixin-class rank-class drop 3 ;
 
 : redefine-mixin-class ( class members -- )
-    dupd define-union-class
-    t "mixin" set-word-prop ;
+    [ (define-union-class) ]
+    [ drop t "mixin" set-word-prop ]
+    2bi ;
 
 : define-mixin-class ( class -- )
     dup mixin-class? [
@@ -30,17 +31,36 @@ TUPLE: check-mixin-class mixin ;
     ] unless ;
 
 : if-mixin-member? ( class mixin true false -- )
-    >r >r check-mixin-class 2dup members memq? r> r> if ; inline
+    [ check-mixin-class 2dup members memq? ] 2dip if ; inline
 
 : change-mixin-class ( class mixin quot -- )
-    [ members swap bootstrap-word ] prepose keep
+    [ [ members swap bootstrap-word ] dip call ] [ drop ] 2bi
     swap redefine-mixin-class ; inline
 
+: update-classes/new ( mixin -- )
+    class-usages
+    [ keys [ update-class ] each ]
+    [ implementors [ make-generic ] each ] bi ;
+
 : add-mixin-instance ( class mixin -- )
-    [ 2drop ] [ [ suffix ] change-mixin-class ] if-mixin-member? ;
+    #! Note: we call update-classes on the new member, not the
+    #! mixin. This ensures that we only have to update the
+    #! methods whose specializer intersects the new member, not
+    #! the entire mixin (since the other mixin members are not
+    #! affected at all). Also, all usages of the mixin will get
+    #! updated by transitivity; the mixins usages appear in
+    #! class-usages of the member, now that it's been added.
+    [ 2drop ] [
+        [ [ suffix ] change-mixin-class ] 2keep
+        nip update-classes
+        ! over new-class? [ nip update-classes/new ] [ drop update-classes ] if
+    ] if-mixin-member? ;
 
 : remove-mixin-instance ( class mixin -- )
-    [ [ swap remove ] change-mixin-class ] [ 2drop ] if-mixin-member? ;
+    [
+        [ [ swap remove ] change-mixin-class ] keep
+        update-classes
+    ] [ 2drop ] if-mixin-member? ;
 
 ! Definition protocol implementation ensures that removing an
 ! INSTANCE: declaration from a source file updates the mixin.
index 4e6ce0d2bb9922e2980c3d9234ea4aa3237f266e..0b54d7d69f883430b6183fbdd8af3c4a8576479c 100755 (executable)
@@ -176,7 +176,7 @@ M: tuple-class update-class
         2drop
         [
             [ update-tuples-after ]
-            [ changed-definition ]
+            [ +inlined+ changed-definition ]
             [ redefined ]
             tri
         ] each-subclass
index 923c11183f801a83bc1420e439b0798b768381ce..74e29cfb01b47e974c5d2c03d4367fb058eb232e 100755 (executable)
@@ -22,10 +22,11 @@ PREDICATE: union-class < class
 
 M: union-class update-class define-union-predicate ;
 
+: (define-union-class) ( class members -- )
+    f swap f union-class define-class ;
+
 : define-union-class ( class members -- )
-    [ f swap f union-class define-class ]
-    [ drop update-classes ]
-    2bi ;
+    [ (define-union-class) ] [ drop update-classes ] 2bi ;
 
 M: union-class reset-class
     { "class" "metaclass" "members" } reset-props ;
diff --git a/core/compiler/tests/redefine.factor b/core/compiler/tests/redefine.factor
new file mode 100644 (file)
index 0000000..b87898c
--- /dev/null
@@ -0,0 +1,14 @@
+IN: compiler.tests
+USING: compiler tools.test math parser ;
+
+GENERIC: method-redefine-test ( a -- b )
+
+M: integer method-redefine-test 3 + ;
+
+: method-redefine-test-1 ( -- b ) 3 method-redefine-test ;
+
+[ 6 ] [ method-redefine-test-1 ] unit-test
+
+[ ] [ "IN: compiler.tests USE: math M: fixnum method-redefine-test 4 + ;" eval ] unit-test
+
+[ 7 ] [ method-redefine-test-1 ] unit-test
index 49f11c0d11ef11351341093f9458e83890753fff..68c85d6d972be8c9e3afb8e5eed7ef591397e1f6 100755 (executable)
@@ -81,11 +81,11 @@ IN: compiler.tests
 
 [ ] [ dummy-if-2 ] unit-test
 
-: dummy-if-3 ( -- ) t [ 1 ] [ 2 ] if ;
+: dummy-if-3 ( -- ) t [ 1 ] [ 2 ] if ;
 
 [ 1 ] [ dummy-if-3 ] unit-test
 
-: dummy-if-4 ( -- ) f [ 1 ] [ 2 ] if ;
+: dummy-if-4 ( -- ) f [ 1 ] [ 2 ] if ;
 
 [ 2 ] [ dummy-if-4 ] unit-test
 
@@ -140,12 +140,12 @@ DEFER: countdown-b
 [ 16 ] [ 4 dummy-when-3 ] unit-test
 [ f ] [ f dummy-when-3 ] unit-test
 
-: dummy-when-4 ( a -- b c ) dup [ dup dup fixnum* fixnum* ] when swap ;
+: dummy-when-4 ( a b -- a b ) dup [ dup dup fixnum* fixnum* ] when swap ;
 
 [ 64 f ] [ f 4 dummy-when-4 ] unit-test
 [ f t ] [ t f dummy-when-4 ] unit-test
 
-: dummy-when-5 ( -- ) f [ dup fixnum* ] when ;
+: dummy-when-5 ( a -- b ) f [ dup fixnum* ] when ;
 
 [ f ] [ f dummy-when-5 ] unit-test
 
index 6acd3a6415a4c49afe885a6096bd74d93672fe16..658a64315ee45c2805eef4e8a45c78a6b496af38 100755 (executable)
@@ -73,7 +73,7 @@ SYMBOL: outdated-tuples
 SYMBOL: update-tuples-hook
 
 : call-recompile-hook ( -- )
-    changed-definitions get keys [ word? ] filter
+    changed-definitions get [ drop word? ] assoc-filter
     compiled-usages recompile-hook get call ;
 
 : call-update-tuples-hook ( -- )
@@ -82,8 +82,7 @@ SYMBOL: update-tuples-hook
 : finish-compilation-unit ( -- )
     call-recompile-hook
     call-update-tuples-hook
-    dup [ drop crossref? ] assoc-contains? modify-code-heap
-     ;
+    dup [ drop crossref? ] assoc-contains? modify-code-heap ;
 
 : with-nested-compilation-unit ( quot -- )
     [
@@ -97,6 +96,7 @@ SYMBOL: update-tuples-hook
         H{ } clone changed-definitions set
         H{ } clone forgotten-definitions set
         H{ } clone outdated-tuples set
+        H{ } clone new-classes set
         <definitions> new-definitions set
         <definitions> old-definitions set
         [
index 122205eb26f8682c5de355999cb17b5a38665789..0a83e43097348ca580d18c2035b450b75f8c8156 100755 (executable)
@@ -7,10 +7,21 @@ ERROR: no-compilation-unit definition ;
 
 SYMBOL: changed-definitions
 
-: changed-definition ( defspec -- )
-    dup changed-definitions get
-    [ no-compilation-unit ] unless*
-    set-at ;
+SYMBOL: +inlined+
+SYMBOL: +called+
+
+: changed-definition ( defspec how -- )
+    swap changed-definitions get
+    [ set-at ] [ no-compilation-unit ] if* ;
+
+SYMBOL: new-classes
+
+: new-class ( word -- )
+    dup new-classes get
+    [ set-at ] [ no-compilation-unit ] if* ;
+
+: new-class? ( word -- ? )
+    new-classes get key? ;
 
 GENERIC: where ( defspec -- loc )
 
index 9e37ba4c85d66dba99a27ac863ef3b8ee0ca7b06..66beae443f9022509d44754f97639cbe7d50c020 100644 (file)
@@ -2,7 +2,9 @@ USING: help.markup help.syntax math strings words ;
 IN: effects
 
 ARTICLE: "effect-declaration" "Stack effect declaration"
-"It is good practice to declare the stack effects of words using the following syntax:"
+"Stack effects of words must be declared, with the exception of words which only push literals on the stack."
+$nl
+"Stack effects are declared with the following syntax:"
 { $code ": sq ( x -- y ) dup * ;" }
 "A stack effect declaration is written in parentheses and lists word inputs and outputs, separated by " { $snippet "--" } ". Stack effect declarations are read in using a parsing word:"
 { $subsection POSTPONE: ( }
@@ -28,18 +30,21 @@ $nl
 ARTICLE: "effects" "Stack effects"
 "A " { $emphasis "stack effect declaration" } ", for example " { $snippet "( x y -- z )" } " denotes that an operation takes two inputs, with " { $snippet "y" } " at the top of the stack, and returns one output."
 $nl
+"Stack effects of words can be declared."
+{ $subsection "effect-declaration" }
 "Stack effects are first-class, and words for working with them are found in the " { $vocab-link "effects" } " vocabulary."
 { $subsection effect }
 { $subsection effect? }
-"Stack effects of words can be declared."
-{ $subsection "effect-declaration" }
+"There is a literal syntax for stack objects. It is most often used with " { $link define-declared } "."
+{ $subsection POSTPONE: (( }
 "Getting a word's declared stack effect:"
 { $subsection stack-effect }
 "Converting a stack effect to a string form:"
 { $subsection effect>string }
 "Comparing effects:"
 { $subsection effect-height }
-{ $subsection effect<= } ;
+{ $subsection effect<= }
+{ $see-also "inference" } ;
 
 ABOUT: "effects"
 
index 1c2b2f766d6952f29262a1b2305d3961da79a6c0..c592ef6c92e21e7ad03fe9d6fe015b560c2a15ee 100644 (file)
@@ -8,4 +8,10 @@ USING: effects tools.test prettyprint accessors sequences ;
 [ f ] [ 2 3 <effect> 2 2 <effect> effect<= ] unit-test
 [ 2 ] [ (( a b -- c )) in>> length ] unit-test
 [ 1 ] [ (( a b -- c )) out>> length ] unit-test
+
+
+[ "(( a b -- c d ))" ] [ { "a" "b" } { "c" "d" } <effect> unparse ] unit-test
+[ "(( -- c d ))" ] [ { } { "c" "d" } <effect> unparse ] unit-test
+[ "(( a b -- ))" ] [ { "a" "b" } { } <effect> unparse ] unit-test
+[ "(( -- ))" ] [ { } { } <effect> unparse ] unit-test
 [ "(( a b -- c ))" ] [ (( a b -- c )) unparse ] unit-test
index c99de94ded4cb9430315a6f283a47066d2f461f5..fb9820008a575abef8584fc07a5c4f3e7ff98c0c 100755 (executable)
@@ -56,8 +56,19 @@ TUPLE: check-method class generic ;
         \ check-method boa throw
     ] unless ; inline
 
-: with-methods ( generic quot -- )
-    swap [ "methods" word-prop swap call ] keep make-generic ;
+: affected-methods ( class generic -- seq )
+    "methods" word-prop swap
+    [ nip classes-intersect? ] curry assoc-filter
+    values ;
+
+: update-generic ( class generic -- )
+    [ affected-methods [ +called+ changed-definition ] each ]
+    [ make-generic ]
+    bi ;
+
+: with-methods ( class generic quot -- )
+    [ [ "methods" word-prop ] dip call ]
+    [ drop update-generic ] 3bi ;
     inline
 
 : method-word-name ( class word -- string )
@@ -140,15 +151,17 @@ M: method-body forget*
 M: method-body smart-usage
     "method-generic" word-prop smart-usage ;
 
-: implementors* ( classes -- words )
+GENERIC: implementors ( class/classes -- seq )
+
+M: class implementors
+    all-words [ "methods" word-prop key? ] with filter ;
+
+M: assoc implementors
     all-words [
-        "methods" word-prop keys
+         "methods" word-prop keys
         swap [ key? ] curry contains?
     ] with filter ;
 
-: implementors ( class -- seq )
-    dup associate implementors* ;
-
 : forget-methods ( class -- )
     [ implementors ] [ [ swap 2array ] curry ] bi map forget-all ;
 
@@ -164,8 +177,8 @@ M: class forget* ( class -- )
     ]
     [ call-next-method ] bi ;
 
-M: assoc update-methods ( assoc -- )
-    implementors* [ make-generic ] each ;
+M: assoc update-methods ( class assoc -- )
+    implementors [ update-generic ] with each ;
 
 : define-generic ( word combination -- )
     over "combination" word-prop over = [
index 24f64eaab12b5ae47e35fadf38191418eb18de30..2fd867f442cb102c87f0f6e6859a2b8ea41c23cd 100755 (executable)
@@ -62,7 +62,7 @@ HELP: effect-error
 { $error-description "Thrown when a word's inferred stack effect does not match its declared stack effect." } ;
 
 HELP: missing-effect
-{ $error-description "Thrown when inference encounters a word lacking a stack effect declaration. Words not declared " { $link POSTPONE: inline } " must declare a stack effect in order to compile." } ;
+{ $error-description "Thrown when inference encounters a word lacking a stack effect declaration. Stack effects of words must be declared, with the exception of words which only push literals on the stack." } ;
 
 HELP: recursive-quotation-error
 { $error-description "Thrown when a quotation calls itself, directly or indirectly, within the same word. Stack effect inference becomes equivalent to the halting problem if quotation recursion has to be taken into account, hence it is not permitted." }
index 9c28d49dd8f7728ef845caba02056389733afc0b..4a750402431ef7025e2097b596d2777c6fb85cb8 100644 (file)
@@ -5,14 +5,14 @@ USING: inference.backend inference.dataflow kernel generic
 sequences prettyprint io words arrays inspector effects debugger
 assocs accessors ;
 
+M: inference-error error-help error>> error-help ;
+
 M: inference-error error.
     dup rstate>>
     keys [ dup value? [ value-literal ] when ] map
     dup empty? [ "Word: " write dup peek . ] unless
     swap error>> error. "Nesting: " write . ;
 
-M: inference-error error-help drop f ;
-
 M: unbalanced-branches-error error.
     "Unbalanced branches:" print
     [ quots>> ] [ in>> ] [ out>> [ length ] map ] tri 3array flip
index 7858077bef6c8bbc103279427bf01b9835187add..5900e5a844412e6038bf41f622921c631bb2cb36 100755 (executable)
@@ -108,7 +108,8 @@ $nl
 { $subsection "inference-limitations" }
 { $subsection "inference-errors" }
 { $subsection "dataflow-graphs" }
-{ $subsection "compiler-transforms" } ;
+{ $subsection "compiler-transforms" }
+{ $see-also "effects" } ;
 
 ABOUT: "inference"
 
index c63786dc9e6390404ed7e77358ab094e45d22882..21f59bf0204f487a65b071481b5125420cfb1d79 100644 (file)
@@ -1,5 +1,6 @@
 IN: inference.state.tests
-USING: tools.test inference.state words kernel namespaces ;
+USING: tools.test inference.state words kernel namespaces
+definitions ;
 
 : computing-dependencies ( quot -- dependencies )
     H{ } clone [ dependencies rot with-variable ] keep ;
index 9cc1b80f9adfd609f068f3b9d8ec8c6605c999ff..1d1ccaa2a9f638df10a9aabf521904e5a90d4326 100755 (executable)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: assocs namespaces sequences kernel words ;
+USING: assocs namespaces sequences kernel definitions ;
 IN: inference.state
 
 ! Nesting state to solve recursion
index 0e79ed2632d1dfb454fe1523e7b6285a0a301dcd..f90dd2350c5c3e808485e3131f1249675cd9c10f 100755 (executable)
@@ -6,7 +6,7 @@ classes ;
 : compose-n-quot ( word -- quot' ) <repetition> >quotation ;
 : compose-n ( quot -- ) compose-n-quot call ;
 \ compose-n [ compose-n-quot ] 2 define-transform
-: compose-n-test ( -- x ) 2 \ + compose-n ;
+: compose-n-test ( a b c -- x ) 2 \ + compose-n ;
 
 [ 6 ] [ 1 2 3 compose-n-test ] unit-test
 
index 0040629edd444786c06184f78f5b03d064c70025..5ca10c75450d67b4ba4068e87962cfa7dfa036aa 100755 (executable)
@@ -3,7 +3,7 @@
 USING: arrays kernel words sequences generic math namespaces
 quotations assocs combinators math.bitfields inference.backend
 inference.dataflow inference.state classes.tuple.private effects
-inspector hashtables classes generic sets ;
+inspector hashtables classes generic sets definitions ;
 IN: inference.transforms
 
 : pop-literals ( n -- rstate seq )
index 393264e459e89905926274a9f0fe5d1975f26374..9e8f805acf0217a17a1bd99f14c65b471e8fb755 100755 (executable)
@@ -7,7 +7,7 @@ combinators classes classes.algebra generic.math
 optimizer.math.partial continuations optimizer.def-use
 optimizer.backend generic.standard optimizer.specializers
 optimizer.def-use optimizer.pattern-match generic.standard
-optimizer.control kernel.private ;
+optimizer.control kernel.private definitions ;
 IN: optimizer.inlining
 
 : remember-inlining ( node history -- )
@@ -61,12 +61,8 @@ DEFER: (flat-length)
     [ dispatch# node-class# ] keep specific-method ;
 
 : inline-standard-method ( node word -- node )
-    2dup dispatching-class dup [
-        over +inlined+ depends-on
-        swap method 1quotation f splice-quot
-    ] [
-        3drop t
-    ] if ;
+    2dup dispatching-class dup
+    [ swap method 1quotation f splice-quot ] [ 3drop t ] if ;
 
 ! Partial dispatch of math-generic words
 : normalize-math-class ( class -- class' )
index 4484c2ae54ade6e1be4631a45f39424c267028f9..e99f2b850bd4f5c75f7e4b6d271a0e65da5b9be0 100755 (executable)
@@ -359,9 +359,8 @@ M: staging-violation summary
     "A parsing word cannot be used in the same file it is defined in." ;
 
 : execute-parsing ( word -- )
-    [ changed-definitions get key? [ staging-violation ] when ]
-    [ execute ]
-    bi ;
+    dup changed-definitions get key? [ staging-violation ] when
+    execute ;
 
 : parse-step ( accum end -- accum ? )
     scan-word {
index f5ec263f117d0d969c7d2dc12d10d1cc2f34e79d..d5f4dd5906f80c8b00215422785de28b588ae333 100755 (executable)
@@ -34,23 +34,6 @@ unit-test
 
 [ "SBUF\" hello world\"" ] [ SBUF" hello world" unparse ] unit-test
 
-
-[ "( a b -- c d )" ] [
-    { "a" "b" } { "c" "d" } <effect> effect>string
-] unit-test
-
-[ "( -- c d )" ] [
-    { } { "c" "d" } <effect> effect>string
-] unit-test
-
-[ "( a b -- )" ] [
-    { "a" "b" } { } <effect> effect>string
-] unit-test
-
-[ "( -- )" ] [
-    { } { } <effect> effect>string
-] unit-test
-
 [ "W{ \\ + }" ] [ [ W{ \ + } ] first unparse ] unit-test
 
 [ ] [ \ fixnum see ] unit-test
index 2a0f5d289ff9364072a0b31407012ab56248fc5e..f3436c9a916713972491e5daa36abc731fd395ef 100755 (executable)
@@ -53,11 +53,13 @@ M: compose length
     [ compose-first length ]
     [ compose-second length ] bi + ;
 
-M: compose nth
+M: compose virtual-seq compose-first ;
+
+M: compose virtual@
     2dup compose-first length < [
         compose-first
     ] [
         [ compose-first length - ] [ compose-second ] bi
-    ] if nth ;
+    ] if ;
 
-INSTANCE: compose immutable-sequence
+INSTANCE: compose virtual-sequence
index 29facb31f286512429de8c2f8a5d36812f05a03f..8cd86606bce4a2ded364c1ac3be196d5f555960b 100755 (executable)
@@ -118,19 +118,11 @@ HELP: define-slot-word
 { $description "Defines " { $snippet "word" } " to be a simple type-checking generic word that receives the slot number on the stack as a fixnum." }
 $low-level-note ;
 
-HELP: reader-effect
-{ $values { "class" class } { "spec" slot-spec } { "effect" "an instance of " { $link effect } } }
-{ $description "The stack effect of slot reader words is " { $snippet "( object -- value )" } "." } ;
-
 HELP: define-reader
 { $values { "class" class } { "name" string } { "slot" integer } }
 { $description "Defines a reader word to read a slot from instances of " { $snippet "class" } "." }
 $low-level-note ;
 
-HELP: writer-effect
-{ $values { "class" class } { "spec" slot-spec } { "effect" "an instance of " { $link effect } } }
-{ $description "The stack effect of slot writer words is " { $snippet "( value obj -- )" } "." } ;
-
 HELP: define-writer
 { $values { "class" class } { "name" string } { "slot" integer } }
 { $description "Defines a generic word " { $snippet "writer" } " to write a new value to a slot in instances of " { $snippet "class" } "." }
index d3db24157574c7667095e7edbb3e84c120194ad3..db1b875eb60fca3f52807d0668b56445181a52d8 100755 (executable)
@@ -319,9 +319,9 @@ HELP: POSTPONE:
 { $notes "This word is used inside parsing words to delegate further action to another parsing word, and to refer to parsing words literally from literal arrays and such." } ;
 
 HELP: :
-{ $syntax ": word definition... ;" }
+{ $syntax ": word ( stack -- effect ) definition... ;" }
 { $values { "word" "a new word to define" } { "definition" "a word definition" } }
-{ $description "Defines a word in the current vocabulary." }
+{ $description "Defines a word with the given stack effect in the current vocabulary. The stack effect is optional for words which only push literals on the stack." }
 { $examples { $code ": ask-name ( -- name )\n    \"What is your name? \" write readln ;\n: greet ( name -- )\n    \"Greetings, \" write print ;\n: friend ( -- )\n    ask-name greet ;" } } ;
 
 { POSTPONE: : POSTPONE: ; define } related-words
@@ -413,13 +413,21 @@ HELP: (
 { $syntax "( inputs -- outputs )" }
 { $values { "inputs" "a list of tokens" } { "outputs" "a list of tokens" } }
 { $description "Declares the stack effect of the most recently defined word, storing a new " { $link effect } " instance in the " { $snippet "\"declared-effect\"" } " word property." }
-{ $notes "Words must have a declared stack effect to compile. See " { $link "effect-declaration" } " for details." } ;
+{ $notes "All words except those only pushing literals on the stack must have a stack effect declaration. See " { $link "effect-declaration" } " for details." } ;
 
 HELP: ((
 { $syntax "(( inputs -- outputs ))" }
 { $values { "inputs" "a list of tokens" } { "outputs" "a list of tokens" } }
 { $description "Literal stack effect syntax." }
-{ $notes "Useful for meta-programming with " { $link define-declared } "." } ;
+{ $notes "Useful for meta-programming with " { $link define-declared } "." }
+{ $examples
+    { $code
+        "SYMBOL: my-dynamic-word"
+        "USING: math random words ;"
+        "3 { [ + ] [ - ] [ * ] [ / ] } random curry"
+        "(( x -- y )) define-declared"
+    }
+} ;
 
 HELP: !
 { $syntax "! comment..." }
index 7111c2789b9d0e7a84f4439a8baa682b8e23c04f..22d22d83fbf0a249923cd27b0512cb7ceca995d8 100755 (executable)
@@ -114,16 +114,20 @@ compiled-crossref global [ H{ } assoc-like ] change-at
     dup compiled-unxref
     compiled-crossref get delete-at ;
 
-SYMBOL: +inlined+
-SYMBOL: +called+
-
 : compiled-usage ( word -- assoc )
     compiled-crossref get at ;
 
-: compiled-usages ( words -- seq )
-    [ unique dup ] keep [
-        compiled-usage [ nip +inlined+ eq? ] assoc-filter update
-    ] with each keys ;
+: compiled-usages ( assoc -- seq )
+    clone [
+        dup [
+            [
+                [ compiled-usage ] dip
+                +inlined+ eq? [
+                    [ nip +inlined+ eq? ] assoc-filter
+                ] when
+            ] dip swap update
+        ] curry assoc-each
+    ] keep keys ;
 
 GENERIC: redefined ( word -- )
 
@@ -134,7 +138,7 @@ M: object redefined drop ;
     over unxref
     over redefined
     over set-word-def
-    dup changed-definition
+    dup +inlined+ changed-definition
     dup crossref? [ dup xref ] when drop ;
 
 : define-declared ( word def effect -- )
index 50102d19292973af4a694e1a2e5b727c5486a1cd..7b46aa87de6612be9c51e1f490294d07c4e35d02 100644 (file)
@@ -48,7 +48,7 @@ SYMBOL: elements
 
 TUPLE: element syntax id tag tagclass encoding contentlength newobj objtype ;
 
-: <element> element new ;
+: <element> ( -- element ) element new ;
 
 : set-id ( -- boolean )
     read1 dup elements get set-element-id ;
index 376a75b9a3e40f5f95b80c00d68ac72143335de9..4e113d86d3cc20b5a76747f7aea2d91c891cd0a5 100644 (file)
@@ -1,7 +1,7 @@
 USING: math kernel continuations ;
 IN: benchmark.continuations
 
-: continuations-main
+: continuations-main ( -- )
     100000 [ drop [ continue ] callcc0 ] each-integer ;
 
 MAIN: continuations-main
index 53e9c9a14c6e1e3f5e7ebb2d500d6ebf3e8833e8..029fb61902b0fff084e3788209e967f8732c808e 100644 (file)
@@ -1,7 +1,7 @@
 USING: namespaces math sequences splitting kernel columns ;
 IN: benchmark.dispatch2
 
-: sequences
+: sequences ( -- seq )
     [
         1 ,
         10 >bignum ,
@@ -21,9 +21,9 @@ IN: benchmark.dispatch2
         1 [ + ] curry ,
     ] { } make ;
 
-: don't-flush-me drop ;
+: don't-flush-me ( obj -- ) drop ;
 
-: dispatch-test
+: dispatch-test ( -- )
     1000000 sequences
     [ [ 0 swap nth don't-flush-me ] each ] curry times ;
 
index 409d6d4a0f1866b5dbb6bb8e763686fdb52c232d..6ec15ffb9718a905a800a1f73fa50386dcb3a5c9 100644 (file)
@@ -14,7 +14,7 @@ M: number g drop "number" ;
 
 M: object g drop "object" ;
 
-: objects
+: objects ( -- seq )
     [
         H{ } ,
         \ + <mirror> ,
@@ -42,7 +42,7 @@ M: object g drop "object" ;
         ALIEN: 1234 ,
     ] { } make ;
 
-: dispatch-test
+: dispatch-test ( -- )
     2000000 objects [ [ g drop ] each ] curry times ;
 
 MAIN: dispatch-test
index a92772a9236d7c77b46585e99c4c8f40d92f5fa3..2f989b77231f2b82cbd064b2b8e952534c1754c0 100755 (executable)
@@ -2,7 +2,7 @@ USING: kernel.private kernel sequences math combinators
 sequences.private ;
 IN: benchmark.dispatch4
 
-: foobar-1
+: foobar-1 ( n -- val )
     dup {
         [ 0 eq? [ 0 ] [ "x" ] if ]
         [ 1 eq? [ 1 ] [ "x" ] if ]
@@ -26,7 +26,7 @@ IN: benchmark.dispatch4
         [ 19 eq? [ 19 ] [ "x" ] if ]
     } dispatch ;
 
-: foobar-2
+: foobar-2 ( n -- val )
     {
         { [ dup 0 eq? ] [ drop 0 ] }
         { [ dup 1 eq? ] [ drop 1 ] }
@@ -50,14 +50,14 @@ IN: benchmark.dispatch4
         { [ dup 19 eq? ] [ drop 19 ] }
     } cond ;
 
-: foobar-test-1
+: foobar-test-1 ( -- )
     20000000 [
         20 [
             foobar-1 drop
         ] each
     ] times ;
 
-: foobar-test-2
+: foobar-test-2 ( -- )
     20000000 [
         20 [
             foobar-2 drop
index d449c0fc5b43a0d044ab4dd96a1167f844e585d0..015f762c7b97e75db60a8d8acd3b4925b59a80a0 100755 (executable)
@@ -105,6 +105,6 @@ HINTS: random fixnum ;
 
     ] ;
 
-: run-fasta 2500000 reverse-complement-in fasta ;
+: run-fasta ( -- ) 2500000 reverse-complement-in fasta ;
 
 MAIN: run-fasta
index ad7fb0e7e13620a3f90087e2431d8ff515b9c3e8..20f18032f045f327c04dd127f08b80ab5a4de97d 100644 (file)
@@ -9,6 +9,6 @@ IN: benchmark.fib1
         swap 1 fixnum-fast fast-fixnum-fib fixnum+fast
     ] if ;
 
-: fib-main 34 fast-fixnum-fib 9227465 assert= ;
+: fib-main ( -- ) 34 fast-fixnum-fib 9227465 assert= ;
 
 MAIN: fib-main
index bedfedf6b0f450d12f1bbf29526f8aa9d9a0ed49..043a98f394dfaab317ee95c6f9eab14d6558b98c 100644 (file)
@@ -8,6 +8,6 @@ IN: benchmark.fib2
         1 fixnum- dup fixnum-fib swap 1 fixnum- fixnum-fib fixnum+
     ] if ;
 
-: fib-main 34 fixnum-fib 9227465 assert= ;
+: fib-main ( -- ) 34 fixnum-fib 9227465 assert= ;
 
 MAIN: fib-main
index c2b86f6bfaae102641bc96b98d9b9cc329e909d2..13eaef8e0cd5e387e50cef8c1b24f14176f49806 100644 (file)
@@ -4,6 +4,6 @@ IN: benchmark.fib3
 : fib ( m -- n )
     dup 1 <= [ drop 1 ] [ dup 1 - fib swap 2 - fib + ] if ;
 
-: fib-main 34 fib 9227465 assert= ;
+: fib-main ( -- ) 34 fib 9227465 assert= ;
 
 MAIN: fib-main
index a6415fb50f2efb19a5476fe466024742be390349..7cf756e11f891bbb16845029f990e4fc2a03ba48 100644 (file)
@@ -17,6 +17,6 @@ C: <box> box
         swap box-i swap box-i + <box>
     ] if ;
 
-: fib-main T{ box f 34 } tuple-fib T{ box f 9227465 } assert= ;
+: fib-main ( -- ) T{ box f 34 } tuple-fib T{ box f 9227465 } assert= ;
 
 MAIN: fib-main
index 6f4765af7b9b3a385f66798b7a131766e28750a0..7b33a5b2b410abdcc8cd3c5fefb6c62704d5d76a 100644 (file)
@@ -14,6 +14,6 @@ SYMBOL: n
         ] if
     ] with-scope ;
 
-: fib-main 30 namespace-fib 1346269 assert= ;
+: fib-main ( -- ) 30 namespace-fib 1346269 assert= ;
 
 MAIN: fib-main
index cc42028df638efc787ea024b5654c4c3fb93574c..594b451876e1968c592f0fb788d7f6a4cae04643 100755 (executable)
@@ -1,7 +1,7 @@
 IN: benchmark.fib6\r
 USING: math kernel alien ;\r
 \r
-: fib\r
+: fib ( x -- y )\r
     "int" { "int" } "cdecl" [\r
         dup 1 <= [ drop 1 ] [\r
             1- dup fib swap 1- fib +\r
@@ -9,6 +9,6 @@ USING: math kernel alien ;
     ] alien-callback\r
     "int" { "int" } "cdecl" alien-indirect ;\r
 \r
-: fib-main 25 fib drop ;\r
+: fib-main ( -- ) 25 fib drop ;\r
 \r
 MAIN: fib-main\r
index 61c22d5a295d08beba3fc2ed167e9d3d7bb48fb1..f49d21d5a36829664733903f94b73b54af176758 100644 (file)
@@ -4,14 +4,14 @@ kernel ;
 
 : <range> ( from to -- seq ) dup <slice> ; inline
 
-: vector-iter 100 [ 0 100000 <range> >vector [ ] map drop ] times ;
-: array-iter 100 [ 0 100000 <range> >array [ ] map drop ] times ;
-: string-iter 100 [ 0 100000 <range> >string [ ] map drop ] times ;
-: sbuf-iter 100 [ 0 100000 <range> >sbuf [ ] map drop ] times ;
-: reverse-iter 100 [ 0 100000 <range> >vector <reversed> [ ] map drop ] times ;
-: dot-iter 100 [ 0 100000 <range> dup v. drop ] times ;
+: vector-iter ( -- ) 100 [ 0 100000 <range> >vector [ ] map drop ] times ;
+: array-iter ( -- ) 100 [ 0 100000 <range> >array [ ] map drop ] times ;
+: string-iter ( -- ) 100 [ 0 100000 <range> >string [ ] map drop ] times ;
+: sbuf-iter ( -- ) 100 [ 0 100000 <range> >sbuf [ ] map drop ] times ;
+: reverse-iter ( -- ) 100 [ 0 100000 <range> >vector <reversed> [ ] map drop ] times ;
+: dot-iter ( -- ) 100 [ 0 100000 <range> dup v. drop ] times ;
 
-: iter-main
+: iter-main ( -- )
     vector-iter
     array-iter
     string-iter
index b9b139d7e344835da1aaccd382b2d39cad76c602..5adbb7c66844704d795ee7d350c46029b75fe37b 100755 (executable)
@@ -54,7 +54,7 @@ SYMBOL: cols
 : ppm-header ( w h -- )
     "P6\n" % swap # " " % # "\n255\n" % ;
 
-: buf-size width height * 3 * 100 + ;
+: buf-size ( -- n ) width height * 3 * 100 + ;
 
 : mandel ( -- data )
     [
index fe70246cb5dfc65cc6e0fd2c08e157c0aff42123..18dced09cc293513b72f53189da3eb490ce2f451 100644 (file)
@@ -31,6 +31,6 @@ bit-arrays namespaces io ;
     dup 1- 2^ 10000 * nsieve-bits.
     2 - 2^ 10000 * nsieve-bits. ;
 
-: nsieve-bits-main* 11 nsieve-bits-main ;
+: nsieve-bits-main* ( -- ) 11 nsieve-bits-main ;
 
 MAIN: nsieve-bits-main*
index 7cae1e2a9bc15fca2c25c26587a7a9e30d309f4e..1e327d901a9b929c2b161eeec0d78ab20dc85964 100644 (file)
@@ -30,6 +30,6 @@ arrays namespaces io ;
     dup 1 - 2^ 10000 * nsieve.
     2 - 2^ 10000 * nsieve. ;
 
-: nsieve-main* 9 nsieve-main ;
+: nsieve-main* ( -- ) 9 nsieve-main ;
 
 MAIN: nsieve-main*
index 8eb883241be0b16c5408496ecaffb19675035886..2d8cdc40c7299eb20860ebe1ac2b22410dd4e04e 100644 (file)
@@ -58,6 +58,6 @@ HINTS: gregory fixnum ;
         ] with each
     ] tabular-output ;
 
-: partial-sums-main 2500000 partial-sums ;
+: partial-sums-main ( -- ) 2500000 partial-sums ;
 
 MAIN: partial-sums-main
index 775595709a46ebd6502febd57e766a3523e76f5b..985c9a59b24477dd9f542290990bbe040d8a0cd2 100755 (executable)
@@ -1,7 +1,8 @@
 USING: io.files io.encodings.ascii random math.parser io math ;
 IN: benchmark.random
 
-: random-numbers-path "random-numbers.txt" temp-file ;
+: random-numbers-path ( -- path )
+    "random-numbers.txt" temp-file ;
 
 : write-random-numbers ( n -- )
     random-numbers-path ascii [
index 3ec8cb4245e68212279365276635989bd458da55..7d7ec244fbcde15a239fdefd10187b005effd3c9 100755 (executable)
@@ -169,7 +169,7 @@ DEFER: create ( level c r -- scene )
         [ [ oversampling sq / pgm-pixel ] each ] each
     ] B{ } make ;
 
-: raytracer-main
+: raytracer-main ( -- )
     run "raytracer.pnm" temp-file binary set-file-contents ;
 
 MAIN: raytracer-main
index f69547df6069cc9852a7a2b2c536d3be60297e8e..c8bae8a56ac7e860e1d9e1dd608afc1c2c67e447 100755 (executable)
@@ -32,6 +32,6 @@ IN: benchmark.recursive
 
 HINTS: recursive fixnum ;
 
-: recursive-main 11 recursive ;
+: recursive-main ( -- ) 11 recursive ;
 
 MAIN: recursive-main
index 5fdaf49d8f4bad3132d9d25fece63910a865c497..3af468654f1dc7f40821ab4b0ad0a65a4e9e06e8 100755 (executable)
@@ -38,10 +38,10 @@ HINTS: do-line vector string ;
         ] with-file-reader
     ] with-file-writer ;
 
-: reverse-complement-in
+: reverse-complement-in ( -- path )
     "reverse-complement-in.txt" temp-file ;
 
-: reverse-complement-out
+: reverse-complement-out ( -- path )
     "reverse-complement-out.txt" temp-file ;
 
 : reverse-complement-main ( -- )
index 673a67d93f68b8e6ec5e62c036ecbfb0d3abe865..66c9c11167d8fda2233e332ea46cfb251a90612f 100755 (executable)
@@ -8,7 +8,7 @@ SYMBOL: counter
 
 : number-of-requests 1 ;
 
-: server-addr "127.0.0.1" 7777 <inet4> ;
+: server-addr ( -- addr ) "127.0.0.1" 7777 <inet4> ;
 
 : server-loop ( server -- )
     dup accept drop [
index cd6189fe225cfad28d2e11e9788f0b59a61652a2..983a9e86b1017c066e504e04b00b82d68e8028a8 100755 (executable)
@@ -2,7 +2,7 @@ USING: kernel sequences sorting benchmark.random math.parser
 io.files io.encodings.ascii ;
 IN: benchmark.sort
 
-: sort-benchmark
+: sort-benchmark ( -- )
     random-numbers-path
     ascii file-lines [ string>number ] map
     natural-sort drop ;
index fd7bb6e80295171e31bd74205aaa343ffa652f69..434094a2a38489c91f4160b63bcb33b999e46949 100644 (file)
@@ -3,8 +3,8 @@ IN: benchmark.typecheck1
 
 TUPLE: hello n ;
 
-: foo 0 100000000 [ over hello-n + ] times ;
+: foo ( obj -- obj n ) 0 100000000 [ over hello-n + ] times ;
 
-: typecheck-main 0 hello boa foo 2drop ;
+: typecheck-main ( -- ) 0 hello boa foo 2drop ;
 
 MAIN: typecheck-main
index 0dfcc17c66491fb63c6c65747192306ec2c76f59..f408389e694d2a8630a5a4270324da094f236961 100644 (file)
@@ -3,10 +3,10 @@ IN: benchmark.typecheck2
 
 TUPLE: hello n ;
 
-: hello-n* dup tuple? [ 3 slot ] [ 3 throw ] if ;
+: hello-n* ( obj -- value ) dup tuple? [ 3 slot ] [ 3 throw ] if ;
 
-: foo 0 100000000 [ over hello-n* + ] times ;
+: foo ( obj -- obj n ) 0 100000000 [ over hello-n* + ] times ;
 
-: typecheck-main 0 hello boa foo 2drop ;
+: typecheck-main ( -- ) 0 hello boa foo 2drop ;
 
 MAIN: typecheck-main
index 3ca6a9f9e7b55136b1faea7d55678dc2981773d6..b15d81df566cfe6b699d6986d9953c21be6c74e7 100644 (file)
@@ -3,10 +3,10 @@ IN: benchmark.typecheck3
 
 TUPLE: hello n ;
 
-: hello-n* dup tag 2 eq? [ 3 slot ] [ 3 throw ] if ;
+: hello-n* ( obj -- val ) dup tag 2 eq? [ 3 slot ] [ 3 throw ] if ;
 
-: foo 0 100000000 [ over hello-n* + ] times ;
+: foo ( obj -- obj n ) 0 100000000 [ over hello-n* + ] times ;
 
-: typecheck-main 0 hello boa foo 2drop ;
+: typecheck-main ( -- ) 0 hello boa foo 2drop ;
 
 MAIN: typecheck-main
index cc3310fef6c2b35e70a4106c7be0a2b0d1ecc6c3..a2595810be1358c16b45117f2beb2c1dc20c1a6b 100644 (file)
@@ -3,10 +3,10 @@ IN: benchmark.typecheck4
 
 TUPLE: hello n ;
 
-: hello-n* 3 slot ;
+: hello-n* ( obj -- val ) 3 slot ;
 
-: foo 0 100000000 [ over hello-n* + ] times ;
+: foo ( obj -- obj n ) 0 100000000 [ over hello-n* + ] times ;
 
-: typecheck-main 0 hello boa foo 2drop ;
+: typecheck-main ( -- ) 0 hello boa foo 2drop ;
 
 MAIN: typecheck-main
index 7fcec00e984a6dba2885adf55a269b7c974b0871..7d3ef8975942e10369cb7870046eaf94a45b21c1 100644 (file)
@@ -101,7 +101,7 @@ M: check< summary drop "Number exceeds upper bound" ;
         >ranges filter-pad [ define-setters ] 2keep define-accessors
     ] with-compilation-unit ;
 
-: parse-bitfield 
+: parse-bitfield ( -- )
     scan ";" parse-tokens parse-slots define-bitfield ;
 
 : BITFIELD:
index 29c9d5b072e0ab6ad3520e6a687fa95b925f7f4b..de13b4aed43fc28b2e6e0d2908b2cbbe5f7d06ee 100755 (executable)
@@ -12,9 +12,9 @@ SYMBOL: upload-images-destination
   "slava@factorcode.org:/var/www/factorcode.org/newsite/images/latest/"
   or ;
 
-: checksums "checksums.txt" temp-file ;
+: checksums ( -- temp ) "checksums.txt" temp-file ;
 
-: boot-image-names images [ boot-image-name ] map ;
+: boot-image-names ( -- seq ) images [ boot-image-name ] map ;
 
 : compute-checksums ( -- )
     checksums ascii [
index 8fef44a76a9a82e0cb8f4f38bd316a496b7fac68..b1f2f19d9c03fb6fce09d63c6147b3121615c9e8 100755 (executable)
@@ -38,9 +38,9 @@ IN: bunny.model
     ascii [ parse-model ] with-file-reader
     [ normals ] 2keep 3array ;
 
-: model-path "bun_zipper.ply" temp-file ;
+: model-path ( -- path ) "bun_zipper.ply" temp-file ;
 
-: model-url "http://factorcode.org/bun_zipper.ply" ;
+: model-url ( -- url ) "http://factorcode.org/bun_zipper.ply" ;
 
 : maybe-download ( -- path )
     model-path dup exists? [
index ff1811e9d595aacc58b4ff4e9149b4c6b8323f81..15dee790066fa795173fcc9ed0462c5bafc22ce9 100755 (executable)
@@ -4,46 +4,46 @@ combinators accessors debugger
 calendar calendar.format.macros ;\r
 IN: calendar.format\r
 \r
-: pad-00 number>string 2 CHAR: 0 pad-left ;\r
+: pad-00 ( n -- str ) number>string 2 CHAR: 0 pad-left ;\r
 \r
-: pad-0000 number>string 4 CHAR: 0 pad-left ;\r
+: pad-0000 ( n -- str ) number>string 4 CHAR: 0 pad-left ;\r
 \r
-: pad-00000 number>string 5 CHAR: 0 pad-left ;\r
+: pad-00000 ( n -- str ) number>string 5 CHAR: 0 pad-left ;\r
 \r
-: write-00 pad-00 write ;\r
+: write-00 ( n -- ) pad-00 write ;\r
 \r
-: write-0000 pad-0000 write ;\r
+: write-0000 ( n -- ) pad-0000 write ;\r
 \r
-: write-00000 pad-00000 write ;\r
+: write-00000 ( n -- ) pad-00000 write ;\r
 \r
-: hh hour>> write-00 ;\r
+: hh ( time -- ) hour>> write-00 ;\r
 \r
-: mm minute>> write-00 ;\r
+: mm ( time -- ) minute>> write-00 ;\r
 \r
-: ss second>> >integer write-00 ;\r
+: ss ( time -- ) second>> >integer write-00 ;\r
 \r
-: D day>> number>string write ;\r
+: D ( time -- ) day>> number>string write ;\r
 \r
-: DD day>> write-00 ;\r
+: DD ( time -- ) day>> write-00 ;\r
 \r
-: DAY day-of-week day-abbreviations3 nth write ;\r
+: DAY ( time -- ) day-of-week day-abbreviations3 nth write ;\r
 \r
-: MM month>> write-00 ;\r
+: MM ( time -- ) month>> write-00 ;\r
 \r
-: MONTH month>> month-abbreviations nth write ;\r
+: MONTH ( time -- ) month>> month-abbreviations nth write ;\r
 \r
-: YYYY year>> write-0000 ;\r
+: YYYY ( time -- ) year>> write-0000 ;\r
 \r
-: YYYYY year>> write-00000 ;\r
+: YYYYY ( time -- ) year>> write-00000 ;\r
 \r
 : expect ( str -- )\r
     read1 swap member? [ "Parse error" throw ] unless ;\r
 \r
-: read-00 2 read string>number ;\r
+: read-00 ( -- n ) 2 read string>number ;\r
 \r
-: read-000 3 read string>number ;\r
+: read-000 ( -- n ) 3 read string>number ;\r
 \r
-: read-0000 4 read string>number ;\r
+: read-0000 ( -- n ) 4 read string>number ;\r
 \r
 GENERIC: day. ( obj -- )\r
 \r
@@ -261,7 +261,7 @@ ERROR: invalid-timestamp-format ;
 : timestamp>ymd ( timestamp -- str )\r
     [ (timestamp>ymd) ] with-string-writer ;\r
 \r
-: (timestamp>hms)\r
+: (timestamp>hms) ( timestamp -- )\r
     { hh ":" mm ":" ss } formatted ;\r
 \r
 : timestamp>hms ( timestamp -- str )\r
index a385f6d04f9303fcf8d7be148304fcef8df9b3fb..910c59bdf88569843550921d2c45007248964579 100755 (executable)
@@ -74,7 +74,7 @@ SYMBOLS: a b c d old-a old-b old-c old-d ;
 : S43 15 ; inline
 : S44 21 ; inline
 
-: (process-md5-block-F)
+: (process-md5-block-F) ( block -- block )
     dup S11 1  0  [ F ] ABCD
     dup S12 2  1  [ F ] DABC
     dup S13 3  2  [ F ] CDAB
@@ -92,7 +92,7 @@ SYMBOLS: a b c d old-a old-b old-c old-d ;
     dup S13 15 14 [ F ] CDAB
     dup S14 16 15 [ F ] BCDA ;
 
-: (process-md5-block-G)
+: (process-md5-block-G) ( block -- block )
     dup S21 17 1  [ G ] ABCD
     dup S22 18 6  [ G ] DABC
     dup S23 19 11 [ G ] CDAB
@@ -110,7 +110,7 @@ SYMBOLS: a b c d old-a old-b old-c old-d ;
     dup S23 31 7  [ G ] CDAB
     dup S24 32 12 [ G ] BCDA ;
 
-: (process-md5-block-H)
+: (process-md5-block-H) ( block -- block )
     dup S31 33 5  [ H ] ABCD
     dup S32 34 8  [ H ] DABC
     dup S33 35 11 [ H ] CDAB
@@ -128,7 +128,7 @@ SYMBOLS: a b c d old-a old-b old-c old-d ;
     dup S33 47 15 [ H ] CDAB
     dup S34 48 2  [ H ] BCDA ;
 
-: (process-md5-block-I)
+: (process-md5-block-I) ( block -- block )
     dup S41 49 0  [ I ] ABCD
     dup S42 50 7  [ I ] DABC
     dup S43 51 14 [ I ] CDAB
index f1af0ef15ef07366d165a744298b2b82547d79fd..b0ffb6ae544f56174e0878ac3202cb76555453dd 100755 (executable)
@@ -3,7 +3,7 @@
 !
 USING: kernel math sequences words arrays io io.files namespaces
 math.parser assocs quotations parser parser-combinators
-tools.time io.encodings.binary ;
+tools.time io.encodings.binary sequences.deep symbols combinators ;
 IN: cpu.8080.emulator
 
 TUPLE: cpu b c d e f h l a pc sp halted? last-interrupt cycles ram ;
@@ -563,29 +563,18 @@ SYMBOL: rom-root
     { "M" { flag-m?  } }
   } at ;
 
-SYMBOL: $1
-SYMBOL: $2
-SYMBOL: $3
-SYMBOL: $4
+SYMBOLS: $1 $2 $3 $4 ;
 
 : replace-patterns ( vector tree -- tree )
-  #! Copy the tree, replacing each occurence of 
-  #! $1, $2, etc with the relevant item from the 
-  #! given index.
-  dup quotation? over [ ] = not and [ ! vector tree
-    dup first swap rest ! vector car cdr
-    >r dupd replace-patterns ! vector v R: cdr
-    swap r> replace-patterns >r 1quotation r> append
-  ] [ ! vector value
-    dup $1 = [ drop 0 over nth  ] when 
-    dup $2 = [ drop 1 over nth  ] when 
-    dup $3 = [ drop 2 over nth  ] when 
-    dup $4 = [ drop 3 over nth  ] when 
-    nip
-  ] if ;
-
-: test-rp 
-  { 4 5 3 } [ 1 $2 [ $1 4 ] ] replace-patterns ;
+  [
+    {
+      { $1 [ first ] }
+      { $2 [ second ] }
+      { $3 [ third ] }
+      { $4 [ fourth ] }
+      [ nip ]
+    } case
+  ] with deep-map ;
 
 : (emulate-RST) ( n cpu -- )
   #! RST nn
@@ -766,7 +755,7 @@ SYMBOL: $4
   "H" token  <|>
   "L" token  <|> [ register-lookup ] <@ ;
 
-: all-flags
+: all-flags ( -- parser )
   #! A parser for 16-bit flags. 
   "NZ" token  
   "NC" token <|>
@@ -777,7 +766,7 @@ SYMBOL: $4
   "P" token <|> 
   "M" token <|> [ flag-lookup ] <@ ;
 
-: 16-bit-registers
+: 16-bit-registers ( -- parser )
   #! A parser for 16-bit registers. On a successfull parse the
   #! parse tree contains a vector. The first item in the vector
   #! is the getter word for that register with stack effect
@@ -1098,27 +1087,27 @@ SYMBOL: $4
   16-bit-registers indirect <&>
   just [ first2 swap first2 swap >r prepend r> curry ] <@ ;  
   
-: LD-RR,NN-instruction
+: LD-RR,NN-instruction ( -- parser )
   #! LD BC,nn
   "LD-RR,NN" "LD" complex-instruction
   16-bit-registers sp <&>
   ",nn" token <& 
   just [ first2 swap curry ] <@ ;
 
-: LD-R,N-instruction
+: LD-R,N-instruction ( -- parser )
   #! LD B,n
   "LD-R,N" "LD" complex-instruction
   8-bit-registers sp <&>
   ",n" token <& 
   just [ first2 swap curry ] <@ ;
   
-: LD-(RR),N-instruction
+: LD-(RR),N-instruction ( -- parser )
   "LD-(RR),N" "LD" complex-instruction
   16-bit-registers indirect sp <&> 
   ",n" token <&
   just [ first2 swap curry ] <@ ;
 
-: LD-(RR),R-instruction
+: LD-(RR),R-instruction ( -- parser )
   #! LD (BC),A
   "LD-(RR),R" "LD" complex-instruction
   16-bit-registers indirect sp <&> 
@@ -1126,84 +1115,84 @@ SYMBOL: $4
   8-bit-registers <&>
   just [ first2 swap first2 swap >r prepend r> curry ] <@ ;  
 
-: LD-R,R-instruction
+: LD-R,R-instruction ( -- parser )
   "LD-R,R" "LD" complex-instruction
   8-bit-registers sp <&> 
   "," token <&
   8-bit-registers <&>
   just [ first2 swap first2 swap >r prepend r> curry ] <@ ;  
 
-: LD-RR,RR-instruction
+: LD-RR,RR-instruction ( -- parser )
   "LD-RR,RR" "LD" complex-instruction
   16-bit-registers sp <&> 
   "," token <&
   16-bit-registers <&>
   just [ first2 swap first2 swap >r prepend r> curry ] <@ ;  
 
-: LD-R,(RR)-instruction
+: LD-R,(RR)-instruction ( -- parser )
   "LD-R,(RR)" "LD" complex-instruction
   8-bit-registers sp <&> 
   "," token <&
   16-bit-registers indirect <&>
   just [ first2 swap first2 swap >r prepend r> curry ] <@ ;  
 
-: LD-(NN),RR-instruction
+: LD-(NN),RR-instruction ( -- parser )
   "LD-(NN),RR" "LD" complex-instruction
   "nn" token indirect sp <&
   "," token <&
   16-bit-registers <&>
   just [ first2 swap curry ] <@ ;
 
-: LD-(NN),R-instruction
+: LD-(NN),R-instruction ( -- parser )
   "LD-(NN),R" "LD" complex-instruction
   "nn" token indirect sp <&
   "," token <&
   8-bit-registers <&>
   just [ first2 swap curry ] <@ ;
 
-: LD-RR,(NN)-instruction
+: LD-RR,(NN)-instruction ( -- parser )
   "LD-RR,(NN)" "LD" complex-instruction
   16-bit-registers sp <&>
   "," token <&
   "nn" token indirect <&
   just [ first2 swap curry ] <@ ;
 
-: LD-R,(NN)-instruction
+: LD-R,(NN)-instruction ( -- parser )
   "LD-R,(NN)" "LD" complex-instruction
   8-bit-registers sp <&>
   "," token <&
   "nn" token indirect <&
   just [ first2 swap curry ] <@ ;
 
-: OUT-(N),R-instruction
+: OUT-(N),R-instruction ( -- parser )
   "OUT-(N),R" "OUT" complex-instruction
   "n" token indirect sp <&
   "," token <&
   8-bit-registers <&>
   just [ first2 swap curry ] <@ ;
 
-: IN-R,(N)-instruction
+: IN-R,(N)-instruction ( -- parser )
   "IN-R,(N)" "IN" complex-instruction
   8-bit-registers sp <&>
   "," token <&
   "n" token indirect <&
   just [ first2 swap curry ] <@ ;
 
-: EX-(RR),RR-instruction
+: EX-(RR),RR-instruction ( -- parser )
   "EX-(RR),RR" "EX" complex-instruction
   16-bit-registers indirect sp <&> 
   "," token <&
   16-bit-registers <&>
   just [ first2 swap first2 swap >r prepend r> curry ] <@ ;  
 
-: EX-RR,RR-instruction
+: EX-RR,RR-instruction ( -- parser )
   "EX-RR,RR" "EX" complex-instruction
   16-bit-registers sp <&> 
   "," token <&
   16-bit-registers <&>
   just [ first2 swap first2 swap >r prepend r> curry ] <@ ;  
 
-: 8080-generator-parser
+: 8080-generator-parser ( -- parser )
   NOP-instruction 
   RST-0-instruction <|> 
   RST-8-instruction <|> 
@@ -1296,7 +1285,7 @@ SYMBOL: last-opcode
   #! that would implement that instruction.
   dup " " join instruction-quotations
   >r "_" join [ "emulate-" % % ] "" make create-in dup last-instruction global set-at  
-  r> define ;
+  r> (( cpu -- )) define-declared ;
 
 : INSTRUCTION: ";" parse-tokens parse-instructions ; parsing
 
index 3686afa80cb167976cecd9ae8a2a041b71e8e4b7..4358d7f3de6d5de9a14f618235b7ac24797e95be 100755 (executable)
@@ -281,7 +281,7 @@ FUNCTION: void PQclear ( PGresult* res ) ;
 FUNCTION: void PQfreemem ( void* ptr ) ;
 
 ! Exists for backward compatibility.
-: PQfreeNotify PQfreemem ;
+: PQfreeNotify ( ptr -- ) PQfreemem ;
 
 !
 ! Make an empty PGresult with given status (some apps find this
index ebcc67374b4d74f7f8cb1ed534049cf981a6849f..e99bc414494abe5c44b5c39c4838d11a14cb1aa1 100755 (executable)
@@ -66,10 +66,10 @@ M: postgresql-result-null summary ( obj -- str )
 : param-types ( statement -- seq )
     in-params>> [ type>> type>oid ] map >c-uint-array ;
 
-: malloc-byte-array/length
+: malloc-byte-array/length ( byte-array -- alien length )
     [ malloc-byte-array &free ] [ length ] bi ;
 
-: default-param-value
+: default-param-value ( obj -- alien n )
     number>string* dup [ utf8 malloc-string &free ] when 0 ;
 
 : param-values ( statement -- seq seq2 )
index 82c6e370bd6dfd4456549be8dcb23d5839e63f2c..ae748731b12ae97065b6675ef9f3455d4b88ecb6 100755 (executable)
@@ -7,10 +7,10 @@ SYMBOLS: insert update delete select distinct columns from as
 where group-by having order-by limit offset is-null desc all
 any count avg table values ;
 
-: input-spec, 1, ;
-: output-spec, 2, ;
-: input, 3, ;
-: output, 4, ;
+: input-spec, ( obj -- ) 1, ;
+: output-spec, ( obj -- ) 2, ;
+: input, ( obj -- ) 3, ;
+: output, ( obj -- ) 4, ;
 
 DEFER: sql%
 
index 90306e51817fa269aeef2ab5f709fac302c26b17..66c1b3ec99d3daef5e4e44c2c793d762da6b460f 100755 (executable)
@@ -18,7 +18,7 @@ user "USERS"
     { "deleted" "DELETED" INTEGER +not-null+ }
 } define-persistent
 
-: init-users-table user ensure-table ;
+: init-users-table ( -- ) user ensure-table ;
 
 SINGLETON: users-in-db
 
index 42f132ada1be6cfb00aca0bbc3a8965c70d73f0b..7c5b7a0c810750b15b0e9c28cd70053093e406b9 100644 (file)
@@ -10,7 +10,7 @@ IN: furnace.boilerplate
 
 TUPLE: boilerplate < filter-responder template ;
 
-: <boilerplate> f boilerplate boa ;
+: <boilerplate> ( responder -- boilerplate ) f boilerplate boa ;
 
 M:: boilerplate call-responder* ( path responder -- )
     path responder call-next-method
index 3566d45c5b0e4487c0bccf8c80e95841cb549b1f..99ccf33eec83b555c35c53de6e5f220557399a76 100644 (file)
@@ -86,7 +86,8 @@ M: object modify-form drop ;
 
 SYMBOL: exit-continuation
 
-: exit-with exit-continuation get continue-with ;
+: exit-with ( value -- )
+    exit-continuation get continue-with ;
 
 : with-exit-continuation ( quot -- )
     '[ exit-continuation set @ ] callcc1 exit-continuation off ;
index 16fefe42fc95d050fe1294622857454de70b61a2..b046ee40eb63c5691688bc62310c8c662553d8d0 100755 (executable)
@@ -25,7 +25,7 @@ session "SESSIONS"
 : get-session ( id -- session )
     dup [ <session> select-tuple ] when ;
 
-: init-sessions-table session ensure-table ;
+: init-sessions-table ( -- ) session ensure-table ;
 
 : start-expiring-sessions ( db seq -- )
     '[
index 5926dd596dcf6ff522bda689bd1b6259390c1fb7..06a84929bacdf6c4edfb3e8c799e2aaf7f2fdc5a 100644 (file)
@@ -4,9 +4,9 @@ math.parser math.vectors math.intervals interval-maps memoize
 csv accessors assocs strings math splitting ;
 IN: geo-ip
 
-: db-path "IpToCountry.csv" temp-file ;
+: db-path ( -- path ) "IpToCountry.csv" temp-file ;
 
-: db-url "http://software77.net/cgi-bin/ip-country/geo-ip.pl?action=download" ;
+: db-url ( -- url ) "http://software77.net/cgi-bin/ip-country/geo-ip.pl?action=download" ;
 
 : download-db ( -- path )
     db-path dup exists? [
index d131946ffbf18cb5e7b97273e6ef1dddd8359f23..c7d5413a4721d0d8aa6733cb77d5ad0e72ffb117 100755 (executable)
@@ -6,13 +6,17 @@ IN: globs
 
 <PRIVATE
 
-: 'char' [ ",*?" member? not ] satisfy ;
+: 'char' ( -- parser )
+    [ ",*?" member? not ] satisfy ;
 
-: 'string' 'char' <+> [ >lower token ] <@ ;
+: 'string' ( -- parser )
+    'char' <+> [ >lower token ] <@ ;
 
-: 'escaped-char' "\\" token any-char-parser &> [ 1token ] <@ ;
+: 'escaped-char' ( -- parser )
+    "\\" token any-char-parser &> [ 1token ] <@ ;
 
-: 'escaped-string' 'string' 'escaped-char' <|> ;
+: 'escaped-string' ( -- parser )
+    'string' 'escaped-char' <|> ;
 
 DEFER: 'term'
 
@@ -23,7 +27,7 @@ DEFER: 'term'
     'glob' "," token nonempty-list-of "{" "}" surrounded-by
     [ <or-parser> ] <@ ;
 
-LAZY: 'term'
+LAZY: 'term' ( -- parser )
     'union'
     'character-class' <|>
     "?" token [ drop any-char-parser ] <@ <|>
@@ -32,7 +36,7 @@ LAZY: 'term'
 
 PRIVATE>
 
-: <glob> 'glob' just parse-1 just ;
+: <glob> ( string -- glob ) 'glob' just parse-1 just ;
 
 : glob-matches? ( input glob -- ? )
     [ >lower ] [ <glob> ] bi* parse nil? not ;
index 2599a33754635672ea80dff94f7e0655dbe88377..51af5c594977ada21bf40b8d52b20ade31d229cd 100755 (executable)
@@ -35,7 +35,8 @@ M: winnt total-virtual-mem ( -- n )
 M: winnt available-virtual-mem ( -- n )
     memory-status MEMORYSTATUSEX-ullAvailVirtual ;
 
-: pull-win32-string [ utf16n alien>string ] keep free ;
+: pull-win32-string ( alien -- string )
+    [ utf16n alien>string ] keep free ;
 
 : computer-name ( -- string )
     MAX_COMPUTERNAME_LENGTH 1+ [ malloc ] keep
index 709ecb1b5814165c775a40f113350fdde7b5ac2f..03b3db9cfdf7300a5160dc1ae81a612c6b16ed54 100644 (file)
@@ -1,6 +1,6 @@
 USE: io
 IN: hello-world
 
-: hello "Hello world" print ;
+: hello ( -- ) "Hello world" print ;
 
 MAIN: hello
index c2e12469c559c6fbc67d75aacf0f590208d8cc95..922866649108727df62f2ab35af71e8e39dd3929 100755 (executable)
@@ -11,7 +11,7 @@ $nl
 $nl
 "Factor evaluates code left to right, and stores intermediate values on a " { $emphasis "stack" } ". If you think of the stack as a pile of papers, then " { $emphasis "pushing" } " a value on the stack corresponds to placing a piece of paper at the top of the pile, while " { $emphasis "popping" } " a value corresponds to removing the topmost piece."
 $nl
-"Most words have a " { $emphasis "stack effect declaration" } ", for example " { $snippet "( x y -- z )" } " denotes that a word takes two inputs, with " { $snippet "y" } " at the top of the stack, and returns one output. Stack effect declarations can be viewed by browsing source code, or using tools such as " { $link see } ". See " { $link "effect-declaration" } "."
+"All words except those which only push literals on the stack must have a " { $emphasis "stack effect declaration" } ", for example " { $snippet "( x y -- z )" } " denotes that a word takes two inputs, with " { $snippet "y" } " at the top of the stack, and returns one output. Stack effect declarations can be viewed by browsing source code, or using tools such as " { $link see } "; they are also checked by the compiler. See " { $link "effect-declaration" } "."
 $nl
 "Coming back to the example in the beginning of this article, the following series of steps occurs as the code is evaluated:"
 { $table
@@ -41,7 +41,7 @@ ARTICLE: "cookbook-colon-defs" "Shuffle word and definition cookbook"
 "The " { $link dup } " word makes a copy of the value at the top of the stack:"
 { $example "5 dup * ." "25" }
 "The " { $link sq } " word is actually defined as follows:"
-{ $code ": sq dup * ;" }
+{ $code ": sq ( x -- y ) dup * ;" }
 "(You could have looked this up yourself by clicking on the " { $link sq } " word itself.)"
 $nl
 "Note the key elements in a word definition: The colon " { $link POSTPONE: : } " denotes the start of a word definition. The name of the new word must immediately follow. The word definition then continues on until the " { $link POSTPONE: ; } " token signifies the end of the definition. This type of word definition is called a " { $emphasis "compound definition." }
@@ -60,11 +60,13 @@ $nl
     "This syntax will be familiar to anybody who has used Forth before. However the behavior is slightly different. In most Forth systems, the below code prints 2, because the definition of " { $snippet "b" } " still refers to the previous definition of " { $snippet "a" } ":"
     { $code
         ": a 1 ;"
-        ": b a 1 + ;"
+        ": b ( -- x ) a 1 + ;"
         ": a 2 ;"
         "b ."
     }
     "In Factor, this example will print 3 since word redefinition is explicitly supported."
+    $nl
+    "Indeed, redefining a word twice in the same source file is an error; this is almost always a mistake since there's no way to call the first definition. See " { $link "definition-checking" } "."
 }
 { $references
     { "A whole slew of shuffle words can be used to rearrange the stack. There are forms of word definition other than colon definition, words can be defined entirely at runtime, and word definitions can be " { $emphasis "annotated" } " with tracing calls and breakpoints without modifying the source code." }
index d3c899ece79bdd38a19d34c9c35730f2cf314e9e..6c921fe0a2cf8fc0c69fdff8305e845c57af2165 100755 (executable)
@@ -127,7 +127,7 @@ M: word set-article-parent swap "help-parent" set-word-prop ;
     ":vars - list all variables at error time" print ;
 
 : :help ( -- )
-    error get error-help [ help ] [ "No help for this error. " print ] if
+    error get error-help [ help ] [ "No help for this error. " print ] if*
     :help-debugger ;
 
 : remove-article ( name -- )
index 65120a5d01b977e57fc421c47744e04e861b0ca3..877de30748cb3d6577366d51f8b6e891f192b6fa 100755 (executable)
@@ -18,5 +18,5 @@ IN: help.syntax
 : ABOUT:
     scan-object
     in get vocab
-    dup changed-definition
+    dup +inlined+ changed-definition
     set-vocab-help ; parsing
index 72dabad84e1dbf4e22bf150673f01acf12ecbe5d..42d89811c1fd9e8ca156b5daddba9d27e3331e60 100644 (file)
@@ -10,11 +10,11 @@ IN: html.components
 
 SYMBOL: values
 
-: value values get at ;
+: value ( name -- value ) values get at ;
 
-: set-value values get set-at ;
+: set-value ( value name -- ) values get set-at ;
 
-: blank-values H{ } clone values set ;
+: blank-values ( -- ) H{ } clone values set ;
 
 : prepare-value ( name object -- value name object )
     [ [ value ] keep ] dip ; inline
index 5fe26c284310789afdaa394c9bd54b11e71b4b4e..5fc4bd19aea7054cfbb44b6bc9993122e11bdc31 100644 (file)
@@ -65,7 +65,7 @@ SYMBOL: html
     #! dynamically creating words.
     >r >r elements-vocab create r> r> define-declared ;
 
-: <foo> "<" swap ">" 3append ;
+: <foo> ( str -- <str> ) "<" swap ">" 3append ;
 
 : def-for-html-word-<foo> ( name -- )
     #! Return the name and code for the <foo> patterned
@@ -73,7 +73,7 @@ SYMBOL: html
     dup <foo> swap [ <foo> write-html ] curry
     (( -- )) html-word ;
 
-: <foo "<" prepend ;
+: <foo ( str -- <str ) "<" prepend ;
 
 : def-for-html-word-<foo ( name -- )
     #! Return the name and code for the <foo patterned
@@ -81,21 +81,21 @@ SYMBOL: html
     <foo dup [ write-html ] curry
     (( -- )) html-word ;
 
-: foo> ">" append ;
+: foo> ( str -- foo> ) ">" append ;
 
 : def-for-html-word-foo> ( name -- )
     #! Return the name and code for the foo> patterned
     #! word.
     foo> [ ">" write-html ] (( -- )) html-word ;
 
-: </foo> "</" swap ">" 3append ;
+: </foo> ( str -- </str> ) "</" swap ">" 3append ;
 
 : def-for-html-word-</foo> ( name -- )
     #! Return the name and code for the </foo> patterned
     #! word.
     </foo> dup [ write-html ] curry (( -- )) html-word ;
 
-: <foo/> "<" swap "/>" 3append ;
+: <foo/> ( str -- <str/> ) "<" swap "/>" 3append ;
 
 : def-for-html-word-<foo/> ( name -- )
     #! Return the name and code for the <foo/> patterned
@@ -103,7 +103,7 @@ SYMBOL: html
     dup <foo/> swap [ <foo/> write-html ] curry
     (( -- )) html-word ;
 
-: foo/> "/>" append ;
+: foo/> ( str -- str/> ) "/>" append ;
 
 : def-for-html-word-foo/> ( name -- )
     #! Return the name and code for the foo/> patterned
index e3f45e4c25b31e65951a3d156f0b76129d64923b..eae13f53ada60252c9c8469da01ff1000bc5f379 100755 (executable)
@@ -135,7 +135,7 @@ TUPLE: html-block-stream < html-sub-stream ;
 M: html-block-stream dispose ( quot style stream -- )
     end-sub-stream a-div format-html-div ;
 
-: border-spacing-css,
+: border-spacing-css, ( pair -- )
     "padding: " % first2 max 2 /i # "px; " % ;
 
 : table-style ( style -- str )
index abbf79f860a6a0f4ec144ab718456358d8b0e120..04bebce9260698b6bc9aa997feb76e930d4017aa 100755 (executable)
@@ -16,7 +16,7 @@ EXCLUDE: fry => , ;
 
 IN: http
 
-: crlf "\r\n" write ;
+: crlf ( -- ) "\r\n" write ;
 
 : add-header ( value key assoc -- )
     [ at dup [ "; " rot 3append ] [ drop ] if ] 2keep set-at ;
@@ -135,7 +135,7 @@ cookies ;
 : set-header ( request/response value key -- request/response )
     pick header>> set-at ;
 
-: <request>
+: <request> ( -- request )
     request new
         "1.1" >>version
         <url>
@@ -293,7 +293,7 @@ content-type
 content-charset
 body ;
 
-: <response>
+: <response> ( -- response )
     response new
         "1.1" >>version
         H{ } clone >>header
@@ -301,21 +301,21 @@ body ;
         now timestamp>http-string "date" set-header
         V{ } clone >>cookies ;
 
-: read-response-version
+: read-response-version ( response -- response )
     " \t" read-until
     [ "Bad response: version" throw ] unless
     parse-version
     >>version ;
 
-: read-response-code
+: read-response-code ( response -- response )
     " \t" read-until [ "Bad response: code" throw ] unless
     string>number [ "Bad response: code" throw ] unless*
     >>code ;
 
-: read-response-message
+: read-response-message ( response -- response )
     read-crlf >>message ;
 
-: read-response-header
+: read-response-header ( response -- response )
     read-header >>header
     dup "set-cookie" header parse-cookies >>cookies
     dup "content-type" header [
index a6d894879029f49fd43d9c13098e516636e027b2..626cd78e14e20765f0aa5c036685fff63e08b2c5 100755 (executable)
@@ -5,7 +5,7 @@ combinators arrays io.launcher io http.server.static http.server
 http accessors sequences strings math.parser fry urls ;\r
 IN: http.server.cgi\r
 \r
-: post? request get method>> "POST" = ;\r
+: post? ( -- ? ) request get method>> "POST" = ;\r
 \r
 : cgi-variables ( script-path -- assoc )\r
     #! This needs some work.\r
index 4194ff6609880903c59583c98e0467e5a3a39e04..7b636609b0301173b1e16d20c47d62d234164c95 100755 (executable)
@@ -7,7 +7,7 @@ splitting sorting shuffle symbols sets math.order ;
 IN: koszul
 
 ! Utilities
-: -1^ odd? -1 1 ? ;
+: -1^ ( m -- n ) odd? -1 1 ? ;
 
 : >alt ( obj -- vec )
     {
@@ -18,7 +18,7 @@ IN: koszul
         [ 1array >alt ]
     } cond ;
 
-: canonicalize
+: canonicalize ( assoc -- assoc' )
     [ nip zero? not ] assoc-filter ;
 
 SYMBOL: terms
@@ -207,8 +207,8 @@ DEFER: (d)
     [ v- ] 2map ;
 
 ! Laplacian
-: m.m' dup flip m. ;
-: m'.m dup flip swap m. ;
+: m.m' ( matrix -- matrix' ) dup flip m. ;
+: m'.m ( matrix -- matrix' ) dup flip swap m. ;
 
 : empty-matrix? ( matrix -- ? )
     dup empty? [ drop t ] [ first empty? ] if ;
index f85344651d1e153f328e88ad358c57cc2ca9c9ee..1d5bb49f358960b5ab7723b1d3210829164b7a5c 100644 (file)
@@ -5,11 +5,11 @@
 USING: lists.lazy math kernel sequences quotations ;
 IN: lists.lazy.examples
 
-: naturals 0 lfrom ;
-: positives 1 lfrom ;
-: evens 0 [ 2 + ] lfrom-by ;
-: odds 1 lfrom [ 2 mod 1 = ] lfilter ;
-: powers-of-2 1 [ 2 * ] lfrom-by ;
-: ones 1 [ ] lfrom-by ;
-: squares naturals [ dup * ] lazy-map ;
-: first-five-squares 5 squares ltake list>array ;
+: naturals ( -- list ) 0 lfrom ;
+: positives ( -- list ) 1 lfrom ;
+: evens ( -- list ) 0 [ 2 + ] lfrom-by ;
+: odds ( -- list ) 1 lfrom [ 2 mod 1 = ] lfilter ;
+: powers-of-2 ( -- list ) 1 [ 2 * ] lfrom-by ;
+: ones ( -- list ) 1 [ ] lfrom-by ;
+: squares ( -- list ) naturals [ dup * ] lazy-map ;
+: first-five-squares ( -- list ) 5 squares ltake list>array ;
index cd1429ac53485d9f332c6c2cc0e626026eac1c5c..a074ccd1b9072ebbb44f44b4283faf9b7d2f439f 100755 (executable)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2008 Slava Pestov.\r
 ! See http://factorcode.org/license.txt for BSD license.\r
 USING: kernel sequences namespaces words assocs logging sorting\r
-prettyprint io io.styles strings logging.parser calendar.format ;\r
+prettyprint io io.styles strings logging.parser calendar.format\r
+combinators ;\r
 IN: logging.analysis\r
 \r
 SYMBOL: word-names\r
@@ -41,12 +42,14 @@ SYMBOL: message-histogram
         ] curry assoc-each\r
     ] tabular-output ;\r
 \r
-: log-entry.\r
+: log-entry. ( entry -- )\r
     "====== " write\r
-    dup first (timestamp>string) bl\r
-    dup second pprint bl\r
-    dup third write nl\r
-    fourth "\n" join print ;\r
+    {\r
+        [ first (timestamp>string) bl ]\r
+        [ second pprint bl ]\r
+        [ third write nl ]\r
+        [ fourth "\n" join print ]\r
+    } cleave ;\r
 \r
 : errors. ( errors -- )\r
     [ log-entry. ] each ;\r
index df03bf320b7fbc4ccd9115dcbc820ec0487502b8..6fb7ebd6b13a54b6f2352436cb816dc292e3f037 100755 (executable)
@@ -42,7 +42,7 @@ SYMBOL: log-service
 \r
 <PRIVATE\r
 \r
-: one-string?\r
+: one-string? ( obj -- ? )\r
     {\r
         [ dup array? ]\r
         [ dup length 1 = ]\r
@@ -77,7 +77,7 @@ PRIVATE>
         3drop\r
     ] if ; inline\r
 \r
-: input# stack-effect in>> length ;\r
+: input# ( word -- n ) stack-effect in>> length ;\r
 \r
 : input-logging-quot ( quot word level -- quot' )\r
     rot [ [ input# ] keep ] 2dip '[ , , , log-stack @ ] ;\r
@@ -85,7 +85,7 @@ PRIVATE>
 : add-input-logging ( word level -- )\r
     [ input-logging-quot ] (define-logging) ;\r
 \r
-: output# stack-effect out>> length ;\r
+: output# ( word -- n ) stack-effect out>> length ;\r
 \r
 : output-logging-quot ( quot word level -- quot' )\r
     [ [ output# ] keep ] dip '[ @ , , , log-stack ] ;\r
@@ -121,4 +121,4 @@ PRIVATE>
     #! Syntax: name level\r
     CREATE-WORD dup scan-word\r
     '[ 1array stack>message , , log-message ]\r
-    define ; parsing\r
+    (( message -- )) define-declared ; parsing\r
index c6b073e50199d2215bc20e779f63b8819acd194a..326661fee5df5403e32e3c1d087c7367da914c51 100755 (executable)
@@ -6,31 +6,31 @@ namespaces combinators combinators.lib logging.server
 calendar calendar.format ;\r
 IN: logging.parser\r
 \r
-: string-of satisfy <!*> [ >string ] <@ ;\r
+: string-of ( quot -- parser ) satisfy <!*> [ >string ] <@ ;\r
 \r
 SYMBOL: multiline\r
 \r
-: 'date'\r
+: 'date' ( -- parser )\r
     [ "]" member? not ] string-of [\r
         dup multiline-header =\r
         [ drop multiline ] [ rfc3339>timestamp ] if\r
     ] <@\r
     "[" "]" surrounded-by ;\r
 \r
-: 'log-level'\r
+: 'log-level' ( -- parser )\r
     log-levels [\r
         [ word-name token ] keep [ nip ] curry <@\r
     ] map <or-parser> ;\r
 \r
-: 'word-name'\r
+: 'word-name' ( -- parser )\r
     [ " :" member? not ] string-of ;\r
 \r
 SYMBOL: malformed\r
 \r
-: 'malformed-line'\r
+: 'malformed-line' ( -- parser )\r
     [ drop t ] string-of [ malformed swap 2array ] <@ ;\r
 \r
-: 'log-message'\r
+: 'log-message' ( -- parser )\r
     [ drop t ] string-of [ 1vector ] <@ ;\r
 \r
 MEMO: 'log-line' ( -- parser )\r
@@ -49,7 +49,7 @@ MEMO: 'log-line' ( -- parser )
 : multiline? ( line -- ? )\r
     first multiline eq? ;\r
 \r
-: malformed-line\r
+: malformed-line ( line -- )\r
     "Warning: malformed log line:" print\r
     second print ;\r
 \r
index 2a4e34e01599c3d03e6efc71ed528b35247322fa..f4ad8144bed9f9dbd80989ac63cf6fc297ce363c 100755 (executable)
@@ -67,7 +67,7 @@ SYMBOL: log-files
 : ?delete-file ( path -- )\r
     dup exists? [ delete-file ] [ drop ] if ;\r
 \r
-: delete-oldest keep-logs log# ?delete-file ;\r
+: delete-oldest ( service -- ) keep-logs log# ?delete-file ;\r
 \r
 : ?move-file ( old new -- )\r
     over exists? [ move-file ] [ 2drop ] if ;\r
index 7638550129d2404c613299fc4940201e5d3127b3..a902eda6f78c99587e4cb1e5f74f5bd373a7aef7 100755 (executable)
@@ -69,7 +69,8 @@ SYMBOL: matrix
 : echelon ( matrix -- matrix' )
     [ 0 0 (echelon) ] with-matrix ;
 
-: nonzero-rows [ [ zero? ] all? not ] filter ;
+: nonzero-rows ( matrix -- matrix' )
+    [ [ zero? ] all? not ] filter ;
 
 : null/rank ( matrix -- null rank )
     echelon dup length swap nonzero-rows length [ - ] keep ;
index 294cd6278a7533b2073a1ae0ba33542335a93fa9..529ddb083a9ca9e0ddb2962cea05cf9b5c37bbd6 100755 (executable)
@@ -35,13 +35,13 @@ IN: math.matrices
 
 <PRIVATE
 
-: x first ; inline
-: y second ; inline
-: z third ; inline
+: x ( seq -- elt ) first ; inline
+: y ( seq -- elt ) second ; inline
+: z ( seq -- elt ) third ; inline
 
-: i [ [ y ] [ z ] bi* * ] [ [ z ] [ y ] bi* * ] 2bi - ;
-: j [ [ z ] [ x ] bi* * ] [ [ x ] [ z ] bi* * ] 2bi - ;
-: k [ [ y ] [ x ] bi* * ] [ [ x ] [ y ] bi* * ] 2bi - ;
+: i ( seq1 seq2 -- n ) [ [ y ] [ z ] bi* * ] [ [ z ] [ y ] bi* * ] 2bi - ;
+: j ( seq1 seq2 -- n ) [ [ z ] [ x ] bi* * ] [ [ x ] [ z ] bi* * ] 2bi - ;
+: k ( seq1 seq2 -- n ) [ [ y ] [ x ] bi* * ] [ [ x ] [ y ] bi* * ] 2bi - ;
 
 PRIVATE>
 
index 842c4c7f50a2b845ad3f2546a38ed14e2a007e35..e3adf2277d1b9cf609b9c9f84b3db67092089610 100644 (file)
@@ -54,7 +54,7 @@ PRIVATE>
     #! divide the last two numbers in the sequences
     [ peek ] bi@ / ;
 
-: (p/mod)
+: (p/mod) ( p p -- p p )
     2dup /-last
     2dup , n*p swapd
     p- >vector
index 19cdcab2fbabfc8075cb2f7a225c1e8dc639df7a..25bad4061adc7fc63773cc5dc40c6976b63ea976 100755 (executable)
@@ -177,6 +177,6 @@ IN: minneapolis-talk
     { $slide "Questions?" }
 } ;
 
-: minneapolis-talk minneapolis-slides slides-window ;
+: minneapolis-talk ( -- ) minneapolis-slides slides-window ;
 
 MAIN: minneapolis-talk
index c1ab4400ba65b52e932d8a6e8e91494fcf541be4..e110cb38d3397690b146bffe1cbc98412998df18 100644 (file)
@@ -14,7 +14,7 @@ GENERIC# fmap 1 ( functor quot -- functor' ) inline
 MIXIN: monad
 
 GENERIC: monad-of ( mvalue -- singleton )
-GENERIC: return ( string singleton -- mvalue )
+GENERIC: return ( value singleton -- mvalue )
 GENERIC: fail ( value singleton -- mvalue )
 GENERIC: >>= ( mvalue -- quot )
 
@@ -62,7 +62,7 @@ INSTANCE:  maybe-monad monad
 SINGLETON: nothing
 
 TUPLE: just value ;
-: just \ just boa ;
+: just ( value -- just ) \ just boa ;
 
 UNION: maybe just nothing ;
 INSTANCE: maybe monad
@@ -83,10 +83,10 @@ SINGLETON: either-monad
 INSTANCE:  either-monad monad
 
 TUPLE: left value ;
-: left \ left boa ;
+: left ( value -- left ) \ left boa ;
 
 TUPLE: right value ;
-: right \ right boa ;
+: right ( value -- right ) \ right boa ;
 
 UNION: either left right ;
 INSTANCE: either monad
@@ -131,7 +131,7 @@ SINGLETON: state-monad
 INSTANCE:  state-monad monad
 
 TUPLE: state quot ;
-: state \ state boa ;
+: state ( quot -- state ) \ state boa ;
 
 INSTANCE: state monad
 
@@ -140,7 +140,7 @@ M: state monad-of drop state-monad ;
 M: state-monad return drop '[ , 2array ] state ;
 M: state-monad fail   "Fail" throw ;
 
-: mcall quot>> call ;
+: mcall ( state -- ) quot>> call ;
 
 M: state >>= '[ , _ '[ , mcall first2 @ mcall ] state ] ;
 
@@ -149,14 +149,14 @@ M: state >>= '[ , _ '[ , mcall first2 @ mcall ] state ] ;
 
 : run-st ( state initial -- ) swap mcall second ;
 
-: return-st state-monad return ;
+: return-st ( value -- mvalue ) state-monad return ;
 
 ! Reader
 SINGLETON: reader-monad
 INSTANCE:  reader-monad monad
 
 TUPLE: reader quot ;
-: reader \ reader boa ;
+: reader ( quot -- reader ) \ reader boa ;
 INSTANCE: reader monad
 
 M: reader monad-of drop reader-monad ;
@@ -176,7 +176,7 @@ SINGLETON: writer-monad
 INSTANCE:  writer-monad monad
 
 TUPLE: writer value log ;
-: writer \ writer boa ;
+: writer ( value log -- writer ) \ writer boa ;
 
 M: writer monad-of drop writer-monad ;
 
index 46ad6fc58e93014e396210166d0688ba89cff466..e2a18e2f78b4f248f6e01fec15bdf49b53d1104c 100755 (executable)
@@ -187,7 +187,8 @@ M: method-body crossref?
         drop [ <method> dup ] 2keep reveal-method
     ] if ;
 
-: niceify-method [ dup \ f eq? [ drop f ] when ] map ;
+: niceify-method ( seq -- seq )
+    [ dup \ f eq? [ drop f ] when ] map ;
 
 M: no-method error.
     "Type check error" print
@@ -229,10 +230,10 @@ M: no-method error.
 : create-method-in ( specializer generic -- method )
     create-method dup save-location f set-word ;
 
-: CREATE-METHOD
+: CREATE-METHOD ( -- method )
     scan-word scan-object swap create-method-in ;
 
-: (METHOD:) CREATE-METHOD parse-definition ;
+: (METHOD:) ( -- method def ) CREATE-METHOD parse-definition ;
 
 : METHOD: (METHOD:) define ; parsing
 
index 851f60d126ebd039c8130e27a58ab9803a582d84..9ad8978bf34e26099b84f23360c12a3c0c06e79c 100755 (executable)
@@ -22,25 +22,25 @@ SYMBOL: building-seq
 : get-building-seq ( n -- seq )
     building-seq get nth ;
 
-: n, get-building-seq push ;
-: n% get-building-seq push-all ;
-: n# >r number>string r> n% ;
-
-: 0, 0 n, ;
-: 0% 0 n% ;
-: 0# 0 n# ;
-: 1, 1 n, ;
-: 1% 1 n% ;
-: 1# 1 n# ;
-: 2, 2 n, ;
-: 2% 2 n% ;
-: 2# 2 n# ;
-: 3, 3 n, ;
-: 3% 3 n% ;
-: 3# 3 n# ;
-: 4, 4 n, ;
-: 4% 4 n% ;
-: 4# 4 n# ;
+: n, ( obj n -- ) get-building-seq push ;
+: n% ( seq n -- ) get-building-seq push-all ;
+: n# ( num n -- ) >r number>string r> n% ;
+
+: 0, ( obj -- ) 0 n, ;
+: 0% ( seq -- ) 0 n% ;
+: 0# ( num -- ) 0 n# ;
+: 1, ( obj -- ) 1 n, ;
+: 1% ( seq -- ) 1 n% ;
+: 1# ( num -- ) 1 n# ;
+: 2, ( obj -- ) 2 n, ;
+: 2% ( seq -- ) 2 n% ;
+: 2# ( num -- ) 2 n# ;
+: 3, ( obj -- ) 3 n, ;
+: 3% ( seq -- ) 3 n% ;
+: 3# ( num -- ) 3 n# ;
+: 4, ( obj -- ) 4 n, ;
+: 4% ( seq -- ) 4 n% ;
+: 4# ( num -- ) 4 n# ;
 
 MACRO:: nmake ( quot exemplars -- )
     [let | n [ exemplars length ] |
index 51eb129b34c7fe6e7fd685eff855448038278e2e..b074e85f3b1c8876ef2ce1d49635c52e0b013a0b 100644 (file)
@@ -2,7 +2,7 @@ USING: ui.gadgets.buttons ui.gadgets.packs ui.gadgets ui
 nehe.2 nehe.3 nehe.4 nehe.5 kernel ;
 IN: nehe
 
-: nehe-window
+: nehe-window ( -- )
     [
         [
             "Nehe 2" [ drop run2 ] <bevel-button> gadget,
index 9336aa6b5b2eb52ce082c97b58c9f1b3472ac4ed..ccfe958fe017cf2ee824aaedf922d90e38602173 100644 (file)
@@ -3,12 +3,12 @@ IN: numbers-game
 
 : read-number ( -- n ) readln string>number ;
 
-: guess-banner
+: guess-banner ( -- )
     "I'm thinking of a number between 0 and 100." print ;
-: guess-prompt "Enter your guess: " write ;
-: too-high "Too high" print ;
-: too-low "Too low" print ;
-: correct "Correct - you win!" print ;
+: guess-prompt ( -- ) "Enter your guess: " write ;
+: too-high ( -- ) "Too high" print ;
+: too-low ( -- ) "Too low" print ;
+: correct ( -- ) "Correct - you win!" print ;
 
 : inexact-guess ( actual guess -- )
      < [ too-high ] [ too-low ] if ;
@@ -22,6 +22,6 @@ IN: numbers-game
     dup guess-prompt read-number judge-guess
     [ numbers-game-loop ] [ drop ] if ;
 
-: numbers-game number-to-guess numbers-game-loop ;
+: numbers-game ( -- ) number-to-guess numbers-game-loop ;
 
 MAIN: numbers-game
index 38d61a88230865db461b22ae6293f62691741ec4..2a8959b4a08e16e2823124b599eecae173e90d96 100644 (file)
@@ -245,7 +245,7 @@ SYMBOL: init
     f init set-global
   ] unless ;
 
-: <uint-array> "ALuint" <c-array> ;
+: <uint-array> ( n -- byte-array ) "ALuint" <c-array> ;
 
 : gen-sources ( size -- seq )
   dup <uint-array> 2dup alGenSources swap c-uint-array> ;
index 60b83819d5ee911debb97440549833eb7b26739d..865ece333c53ec34a225661032e692065dc6c3f8 100755 (executable)
@@ -7,7 +7,7 @@ IN: optimizer.report
     >r optimize-1\r
     [ r> 1+ count-optimization-passes ] [ drop r> ] if ;\r
 \r
-: results\r
+: results ( seq -- )\r
     [ [ second ] prepose compare ] curry sort 20 tail*\r
     print\r
     standard-table-style\r
@@ -15,7 +15,7 @@ IN: optimizer.report
         [ [ [ pprint-cell ] each ] with-row ] each\r
     ] tabular-output ;\r
 \r
-: optimizer-report\r
+: optimizer-report ( -- )\r
     all-words [ compiled? ] filter\r
     [\r
         dup [\r
index 3ccc1afe40c646b9f89becec8e69f5a0d23d8f84..d3aec20d80b60c424376d3475bb55d1adcfc9ebc 100644 (file)
@@ -1,5 +1,5 @@
 USING: math math.parser calendar calendar.format strings words
-kernel ;
+kernel effects ;
 IN: present
 
 GENERIC: present ( object -- string )
index 91dea0dd5613fab4fca35ff4d9d366e305de9712..99e6b887c8706d35c1c00fcf315ec595c7916ba7 100755 (executable)
@@ -23,9 +23,9 @@ SYMBOL: ignore-case?
 : or-predicates ( quots -- quot )
     [ \ dup prefix ] map [ [ t ] ] f short-circuit \ nip suffix ;
 
-: <@literal [ nip ] curry <@ ;
+: <@literal ( parser obj -- action ) [ nip ] curry <@ ;
 
-: <@delay [ curry ] curry <@ ;
+: <@delay ( parser quot -- action ) [ curry ] curry <@ ;
 
 PRIVATE>
 
@@ -135,10 +135,10 @@ PRIVATE>
     'posix-character-class' <|>
     'simple-escape' <|> &> ;
 
-: 'any-char'
+: 'any-char' ( -- parser )
     "." token [ drop t ] <@literal ;
 
-: 'char'
+: 'char' ( -- parser )
     'any-char' 'escape' 'ordinary-char' <|> <|> [ satisfy ] <@ ;
 
 DEFER: 'regexp'
diff --git a/extra/regexp2/regexp2-tests.factor b/extra/regexp2/regexp2-tests.factor
deleted file mode 100644 (file)
index 1fb3f61..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-USING: kernel peg regexp2 sequences tools.test ;
-IN: regexp2.tests
-
-[ T{ parse-result f T{ slice f 3 3 "056" } 46 } ]
-    [ "056" 'octal' parse ] unit-test
diff --git a/extra/regexp2/regexp2.factor b/extra/regexp2/regexp2.factor
deleted file mode 100644 (file)
index f7023c7..0000000
+++ /dev/null
@@ -1,262 +0,0 @@
-USING: assocs combinators.lib kernel math math.parser
-namespaces peg unicode.case sequences unicode.categories
-memoize peg.parsers math.order ;
-USE: io
-USE: tools.walker
-IN: regexp2
-
-<PRIVATE
-    
-SYMBOL: ignore-case?
-
-: char=-quot ( ch -- quot )
-    ignore-case? get
-    [ ch>upper [ swap ch>upper = ] ] [ [ = ] ] if
-    curry ;
-    
-: char-between?-quot ( ch1 ch2 -- quot )
-    ignore-case? get
-    [ [ ch>upper ] bi@ [ >r >r ch>upper r> r> between? ] ]
-    [ [ between? ] ]
-    if 2curry ;
-    
-: or-predicates ( quots -- quot )
-    [ \ dup prefix ] map [ [ t ] ] f short-circuit \ nip suffix ;
-
-: literal-action [ nip ] curry action ;
-
-: delay-action [ curry ] curry action ;
-    
-PRIVATE>
-
-: ascii? ( n -- ? )
-    0 HEX: 7f between? ;
-    
-: octal-digit? ( n -- ? ) 
-    CHAR: 0 CHAR: 7 between? ;
-
-: hex-digit? ( n -- ? )
-    {
-        [ dup digit? ]
-        [ dup CHAR: a CHAR: f between? ]
-        [ dup CHAR: A CHAR: F between? ]
-    } || nip ;
-
-: control-char? ( n -- ? )
-    { [ dup 0 HEX: 1f between? ] [ dup HEX: 7f = ] } || nip ;
-
-: punct? ( n -- ? )
-    "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~" member? ;
-
-: c-identifier-char? ( ch -- ? )
-    { [ dup alpha? ] [ dup CHAR: _ = ] } || nip ;
-
-: java-blank? ( n -- ? )
-    {
-        CHAR: \s
-        CHAR: \t CHAR: \n CHAR: \r
-        HEX: c HEX: 7 HEX: 1b
-    } member? ;
-
-: java-printable? ( n -- ? )
-    { [ dup alpha? ] [ dup punct? ] } || nip ;
-
-MEMO: 'ordinary-char' ( -- parser )
-    [ "\\^*+?|(){}[$" member? not ] satisfy
-    [ char=-quot ] action ;
-
-MEMO: 'octal-digit' ( -- parser ) [ octal-digit? ] satisfy ;
-
-MEMO: 'octal' ( -- parser )
-    "0" token hide 'octal-digit' 1 3 from-m-to-n 2seq
-    [ first oct> ] action ;
-
-MEMO: 'hex-digit' ( -- parser ) [ hex-digit? ] satisfy ;
-
-MEMO: 'hex' ( -- parser )
-    "x" token hide 'hex-digit' 2 exactly-n 2seq
-    "u" token hide 'hex-digit' 6 exactly-n 2seq 2choice
-    [ first hex> ] action ;
-
-: satisfy-tokens ( assoc -- parser )
-    [ >r token r> literal-action ] { } assoc>map choice ;
-
-MEMO: 'simple-escape-char' ( -- parser )
-    {
-        { "\\" CHAR: \\ }
-        { "t"  CHAR: \t }
-        { "n"  CHAR: \n }
-        { "r"  CHAR: \r }
-        { "f"  HEX: c   }
-        { "a"  HEX: 7   }
-        { "e"  HEX: 1b  }
-    } [ char=-quot ] assoc-map satisfy-tokens ;
-
-MEMO: 'predefined-char-class' ( -- parser )
-    {   
-        { "d" [ digit? ] } 
-        { "D" [ digit? not ] }
-        { "s" [ java-blank? ] } 
-        { "S" [ java-blank? not ] }
-        { "w" [ c-identifier-char? ] } 
-        { "W" [ c-identifier-char? not ] }
-    } satisfy-tokens ;
-
-MEMO: 'posix-character-class' ( -- parser )
-    {   
-        { "Lower" [ letter? ] }
-        { "Upper" [ LETTER? ] }
-        { "ASCII" [ ascii? ] }
-        { "Alpha" [ Letter? ] }
-        { "Digit" [ digit? ] }
-        { "Alnum" [ alpha? ] }
-        { "Punct" [ punct? ] }
-        { "Graph" [ java-printable? ] }
-        { "Print" [ java-printable? ] }
-        { "Blank" [ " \t" member? ] }
-        { "Cntrl" [ control-char? ] }
-        { "XDigit" [ hex-digit? ] }
-        { "Space" [ java-blank? ] }
-    } satisfy-tokens "p{" "}" surrounded-by ;
-
-MEMO: 'simple-escape' ( -- parser )
-    [
-        'octal' ,
-        'hex' ,
-        "c" token hide [ LETTER? ] satisfy 2seq ,
-        any-char ,
-    ] choice* [ char=-quot ] action ;
-
-MEMO: 'escape' ( -- parser )
-    "\\" token hide [
-        'simple-escape-char' ,
-        'predefined-char-class' ,
-        'posix-character-class' ,
-        'simple-escape' ,
-    ] choice* 2seq ;
-
-MEMO: 'any-char' ( -- parser )
-    "." token [ drop t ] literal-action ;
-
-MEMO: 'char' ( -- parser )
-    'any-char' 'escape' 'ordinary-char' 3choice [ satisfy ] action ;
-
-DEFER: 'regexp'
-
-TUPLE: group-result str ;
-
-C: <group-result> group-result
-
-MEMO: 'non-capturing-group' ( -- parser )
-    "?:" token hide 'regexp' ;
-
-MEMO: 'positive-lookahead-group' ( -- parser )
-    "?=" token hide 'regexp' [ ensure ] action ;
-
-MEMO: 'negative-lookahead-group' ( -- parser )
-    "?!" token hide 'regexp' [ ensure-not ] action ;
-
-MEMO: 'simple-group' ( -- parser )
-    'regexp' [ [ <group-result> ] action ] action ;
-
-MEMO: 'group' ( -- parser )
-    [
-        'non-capturing-group' ,
-        'positive-lookahead-group' ,
-        'negative-lookahead-group' ,
-        'simple-group' ,
-    ] choice* "(" ")" surrounded-by ;
-
-MEMO: 'range' ( -- parser )
-    any-char "-" token hide any-char 3seq
-    [ first2 char-between?-quot ] action ;
-
-MEMO: 'character-class-term' ( -- parser )
-    'range'
-    'escape'
-    [ "\\]" member? not ] satisfy [ char=-quot ] action
-    3choice ;
-
-MEMO: 'positive-character-class' ( -- parser )
-    ! todo
-    "]" token [ CHAR: ] = ] literal-action 'character-class-term' repeat0 2seq 
-    'character-class-term' repeat1 2choice [ or-predicates ] action ;
-
-MEMO: 'negative-character-class' ( -- parser )
-    "^" token hide 'positive-character-class' 2seq
-    [ [ not ] append ] action ;
-
-MEMO: 'character-class' ( -- parser )
-    'negative-character-class' 'positive-character-class' 2choice
-    "[" "]" surrounded-by [ satisfy ] action ;
-
-MEMO: 'escaped-seq' ( -- parser )
-    any-char repeat1
-    [ ignore-case? get token ] action "\\Q" "\\E" surrounded-by ;
-    
-MEMO: 'break' ( quot -- parser )
-    satisfy ensure
-    epsilon just 2choice ;
-    
-MEMO: 'break-escape' ( -- parser )
-    "$" token [ "\r\n" member? ] 'break' literal-action
-    "\\b" token [ blank? ] 'break' literal-action
-    "\\B" token [ blank? not ] 'break' literal-action
-    "\\z" token epsilon just literal-action 4choice ;
-    
-MEMO: 'simple' ( -- parser )
-    [
-        'escaped-seq' ,
-        'break-escape' ,
-        'group' ,
-        'character-class' ,
-        'char' ,
-    ] choice* ;
-
-MEMO: 'exactly-n' ( -- parser )
-    'integer' [ exactly-n ] delay-action ;
-
-MEMO: 'at-least-n' ( -- parser )
-    'integer' "," token hide 2seq [ at-least-n ] delay-action ;
-
-MEMO: 'at-most-n' ( -- parser )
-    "," token hide 'integer' 2seq [ at-most-n ] delay-action ;
-
-MEMO: 'from-m-to-n' ( -- parser )
-    'integer' "," token hide 'integer' 3seq
-    [ first2 from-m-to-n ] delay-action ;
-
-MEMO: 'greedy-interval' ( -- parser )
-    'exactly-n' 'at-least-n' 'at-most-n' 'from-m-to-n' 4choice ;
-
-MEMO: 'interval' ( -- parser )
-    'greedy-interval'
-    'greedy-interval' "?" token hide 2seq [ "reluctant {}" print ] action
-    'greedy-interval' "+" token hide 2seq [ "possessive {}" print ] action
-    3choice "{" "}" surrounded-by ;
-
-MEMO: 'repetition' ( -- parser )
-    [
-        ! Possessive
-        ! "*+" token [ <!*> ] literal-action ,
-        ! "++" token [ <!+> ] literal-action ,
-        ! "?+" token [ <!?> ] literal-action ,
-        ! Reluctant
-        ! "*?" token [ <(*)> ] literal-action ,
-        ! "+?" token [ <(+)> ] literal-action ,
-        ! "??" token [ <(?)> ] literal-action ,
-        ! Greedy
-        "*" token [ repeat0 ] literal-action ,
-        "+" token [ repeat1 ] literal-action ,
-        "?" token [ optional ] literal-action ,
-    ] choice* ;
-
-MEMO: 'dummy' ( -- parser )
-    epsilon [ ] literal-action ;
-
-! todo -- check the action
-! MEMO: 'term' ( -- parser )
-    ! 'simple'
-    ! 'repetition' 'interval' 'dummy' 3choice 2seq [ first2 call ] action
-    ! <!+> [ <and-parser> ] action ;
-
index f94c774943350e0799906cad2e200218f776c3ff..3537d2e719de6fb38af72b1ce17efa40aad9201a 100755 (executable)
@@ -85,7 +85,7 @@ IN: reports.noise
         { spread 2 }\r
     } at 0 or ;\r
 \r
-: vsum { 0 0 } [ v+ ] reduce ;\r
+: vsum ( pairs -- pair ) { 0 0 } [ v+ ] reduce ;\r
 \r
 GENERIC: noise ( obj -- pair )\r
 \r
@@ -105,7 +105,7 @@ M: quotation noise [ noise ] map vsum { 1/4 1/2 } v+ ;
 \r
 M: array noise [ noise ] map vsum ;\r
 \r
-: noise-factor / 100 * >integer ;\r
+: noise-factor ( x y -- z ) / 100 * >integer ;\r
 \r
 : quot-noise-factor ( quot -- n )\r
     #! For very short words, noise doesn't count so much\r
index b58253381cb1085eac99a0c82ff8818a0d70be11..1c8b4fcbb30b76df5006af3a194256c11575c3c8 100755 (executable)
@@ -53,7 +53,7 @@ IN: slides
         gadget.
     ] ($block) ;
 
-: page-theme
+: page-theme ( gadget -- )
     T{ gradient f { { 0.8 0.8 1.0 1.0 } { 0.8 1.0 1.0 1.0 } } }
     swap set-gadget-interior ;
 
index 8fdc0e07a4cf04cdf61a9a2429accc93c856276a..16a13eafe851dddebd4276a8bdc17511663efa71 100755 (executable)
@@ -23,7 +23,7 @@ LOG: log-smtp-connection NOTICE ( addrspec -- )
         call
     ] with-client ; inline
 
-: crlf "\r\n" write ;
+: crlf ( -- ) "\r\n" write ;
 
 : command ( string -- ) write crlf flush ;
 
index 3f1d91d84cff6066a0df901b6dccd9909aba3946..4c83c646416fced30f47fa64de190707baa7a40f 100755 (executable)
@@ -11,8 +11,8 @@ IN: state-machine
 
 TUPLE: state place data ;
 
-TUPLE: missing-state ;
-: missing-state \ missing-state new throw ;
+ERROR: missing-state ;
+
 M: missing-state error.
     drop "Missing state" print ;
 
index b41d7f5023865356dca6406d6c0bafae6eb1bb87..af005b4abe43c9cd20b4e372a22f074b78c83fbf 100644 (file)
@@ -48,7 +48,7 @@ M: expected summary ( obj -- str )
     ] with-string-writer ;\r
 \r
 TUPLE: unexpected-end < parsing-error ;\r
-: unexpected-end \ unexpected-end parsing-error throw ;\r
+: unexpected-end ( -- * ) \ unexpected-end parsing-error throw ;\r
 M: unexpected-end summary ( obj -- str )\r
     [\r
         call-next-method write\r
@@ -56,7 +56,7 @@ M: unexpected-end summary ( obj -- str )
     ] with-string-writer ;\r
 \r
 TUPLE: missing-close < parsing-error ;\r
-: missing-close \ missing-close parsing-error throw ;\r
+: missing-close ( -- * ) \ missing-close parsing-error throw ;\r
 M: missing-close summary ( obj -- str )\r
     [\r
         call-next-method write\r
@@ -111,7 +111,7 @@ SYMBOL: prolog-data
     [ dup get-char = ] take-until nip ;\r
 \r
 TUPLE: not-enough-characters < parsing-error ;\r
-: not-enough-characters\r
+: not-enough-characters ( -- * )\r
     \ not-enough-characters parsing-error throw ;\r
 M: not-enough-characters summary ( obj -- str )\r
     [\r
index 1cb82253b1d5ef884be8b856be4d4e2debf0918b..93b1804e36dc8856e032ef93231ad632103208ee 100644 (file)
@@ -6,12 +6,12 @@ IN: sudoku
 SYMBOL: solutions
 SYMBOL: board
 
-: pair+ swapd + >r + r> ;
+: pair+ ( a b c d -- a+b c+d ) swapd + >r + r> ;
 
-: row board get nth ;
-: board> row nth ;
-: >board row set-nth ;
-: f>board f -rot >board ;
+: row ( n -- row ) board get nth ;
+: board> ( m n -- x ) row nth ;
+: >board ( row m n -- ) row set-nth ;
+: f>board ( m n -- ) f -rot >board ;
 
 : row-contains? ( n y -- ? ) row member? ;
 : col-contains? ( n x -- ? ) board get swap <column> member? ;
index 1f4eb556dc09ce6bf83e39ab4e152c3b9ff0893e..5522dd9bcbded816d3d89ac7ada9c6be254388c1 100644 (file)
@@ -54,7 +54,7 @@ TUPLE: tax-table single married ;
 : <tax-table> ( single married class -- obj )
     >r tax-table boa r> construct-delegate ;
 
-: tax-bracket-range dup second swap first - ;
+: tax-bracket-range ( pair -- n ) dup second swap first - ;
 
 : tax-bracket ( tax salary triples -- tax salary )
     [ [ tax-bracket-range min ] keep third * + ] 2keep
index 0bf8b10d0cb369690d692695e2807c4e83ba606f..0ca85bca8ce9c0a4493047fd7dd99cc8584af643 100755 (executable)
@@ -1,6 +1,6 @@
 IN: tools.deploy.test.1\r
 USING: threads ;\r
 \r
-: deploy-test-1 1000 sleep ;\r
+: deploy-test-1 ( -- ) 1000 sleep ;\r
 \r
 MAIN: deploy-test-1\r
index e029e3050a9c590c9a2cd65da2138d63e7adf93f..afd83f510e5c77a1b7fa118e5038fc78a291b4f1 100755 (executable)
@@ -1,6 +1,6 @@
 IN: tools.deploy.test.2\r
 USING: calendar calendar.format ;\r
 \r
-: deploy-test-2 now (timestamp>string) ;\r
+: deploy-test-2 ( -- ) now (timestamp>string) ;\r
 \r
 MAIN: deploy-test-2\r
index 2f07f4ede519c641214c162bb8c208fa67940fde..69287db4e21c454d7b19eed5bb9ff71f41b51bfa 100755 (executable)
@@ -1,7 +1,7 @@
 IN: tools.deploy.test.3\r
 USING: io.encodings.ascii io.files kernel ;\r
 \r
-: deploy-test-3\r
+: deploy-test-3 ( -- )\r
     "resource:extra/tools/deploy/test/3/3.factor"\r
     ascii file-contents drop ;\r
 \r
index ef5fcf8ca68ffc5eb31f5b208a5b63f2cd2f7749..923df4b6e3e3e628f47f1fc7eb65b5e2fef32028 100755 (executable)
@@ -84,7 +84,7 @@ DEFER: (splay)
 : get-largest ( node -- node )
     dup [ dup node-right [ nip get-largest ] when* ] when ;
 
-: splay-largest
+: splay-largest ( node -- node )
     dup [ dup get-largest node-key swap splay-at ] when ;
 
 : splay-join ( n2 n1 -- node )
index 2936c390701bbd39cc458554f09801521cf539ab..d4b1a34e76701bfecc8ce866dc160507ffceed3d 100644 (file)
@@ -6,6 +6,6 @@ IN: tty-server
     "tty-server"
     utf8 [ listener ] with-server ;
 
-: default-tty-server 9999 tty-server ;
+: default-tty-server ( -- ) 9999 tty-server ;
 
 MAIN: default-tty-server
index 0dc90d8cf5a5219e57daa5afd83d2d3fb2896be9..f5b510237bd6954f05918d66673cb1c0038c944c 100644 (file)
@@ -59,12 +59,12 @@ SYMBOL: tape
     dup state-dir position [ + ] change
     state-next state set ;
 
-: c
+: c ( -- )
     #! Print current turing machine state.
     state get .
     tape get .
     2 position get 2 * + CHAR: \s <string> write "^" print ;
 
-: n
+: n ( -- )
     #! Do one step and print new state.
     turing-step c ;
index 9029d6bd3532b1a928725bede7fbd717e1777f94..66f7c1e7a7e7d1c8ba4b31e4f4aa68cf380deb28 100644 (file)
@@ -26,17 +26,17 @@ IN: units.si
 : cd ( n -- dimensioned ) { cd } { } <dimensioned> ;
 
 ! SI derived units
-: m^2 { m m } { } <dimensioned> ;
-: m^3 { m m m } { } <dimensioned> ;
-: m/s { m } { s } <dimensioned> ;
-: m/s^2 { m } { s s } <dimensioned> ;
-: 1/m { } { m } <dimensioned> ;
-: kg/m^3 { kg } { m m m } <dimensioned> ;
-: A/m^2 { A } { m m } <dimensioned> ;
-: A/m { A } { m } <dimensioned> ;
-: mol/m^3 { mol } { m m m } <dimensioned> ;
-: cd/m^2 { cd } { m m } <dimensioned> ;
-: kg/kg { kg } { kg } <dimensioned> ;
+: m^2 ( n -- dimensioned ) { m m } { } <dimensioned> ;
+: m^3 ( n -- dimensioned ) { m m m } { } <dimensioned> ;
+: m/s ( n -- dimensioned ) { m } { s } <dimensioned> ;
+: m/s^2 ( n -- dimensioned ) { m } { s s } <dimensioned> ;
+: 1/m ( n -- dimensioned ) { } { m } <dimensioned> ;
+: kg/m^3 ( n -- dimensioned ) { kg } { m m m } <dimensioned> ;
+: A/m^2 ( n -- dimensioned ) { A } { m m } <dimensioned> ;
+: A/m ( n -- dimensioned ) { A } { m } <dimensioned> ;
+: mol/m^3 ( n -- dimensioned ) { mol } { m m m } <dimensioned> ;
+: cd/m^2 ( n -- dimensioned ) { cd } { m m } <dimensioned> ;
+: kg/kg ( n -- dimensioned ) { kg } { kg } <dimensioned> ;
 
 ! Radians are really m/m, and steradians are m^2/m^2
 ! but they need to be in reduced form here.
@@ -65,9 +65,9 @@ IN: units.si
 : kat ( n -- katal ) { mol } { s } <dimensioned> ;
 
 ! Extensions to the SI
-: arc-deg pi 180 / * radians ;
-: arc-min pi 10800 / * radians ;
-: arc-sec pi 648000 / * radians ;
+: arc-deg ( n -- x ) pi 180 / * radians ;
+: arc-min ( n -- x ) pi 10800 / * radians ;
+: arc-sec ( n -- x ) pi 648000 / * radians ;
 : L ( n -- liter ) 1/1000 * m^3 ;
 : tons ( n -- metric-ton ) 1000 * kg ;
 : Np ( n -- neper ) { } { } <dimensioned> ;
@@ -83,43 +83,43 @@ IN: units.si
 : bar ( n -- bar ) 100000 * Pa ;
 : b ( n -- barn ) 1/10000000000000000000000000000 * m^2 ;
 : Ci ( n -- curie ) 37000000000 * Bq ;
-: R 258/10000 { s A } { kg } <dimensioned> ;
-: rad 100 / Gy ;
+: R ( -- dimensioned ) 258/10000 { s A } { kg } <dimensioned> ;
+: rad ( n -- dimensioned ) 100 / Gy ;
 
 ! roentgen equivalent man, equal to one roentgen of X-rays
-: roentgen-equivalent-man 100 / Sv ;
+: roentgen-equivalent-man ( n -- dimensioned ) 100 / Sv ;
 
 ! inaccurate, use calendar where possible
-: minutes 60 * s ;
-: hours 60 * minutes ;
-: days 24 * hours ;
+: minutes ( n -- dimensioned ) 60 * s ;
+: hours ( n -- dimensioned ) 60 * minutes ;
+: days ( n -- dimensioned ) 24 * hours ;
 
 ! Y Z E P T G M k h da 1 d c m mu n p f a z y
-: yotta 1000000000000000000000000 * ;
-: zetta 1000000000000000000000 * ;
-: exa   1000000000000000000 * ;
-: peta  1000000000000000 * ;
-: tera  1000000000000 * ;
-: giga  1000000000 * ;
-: mega  1000000 * ;
-: kilo  1000 * ;
-: hecto 100 * ;
-: deca  10 * ;
-: deci  10 / ;
-: centi 100 / ;
-: milli 1000 / ;
-: micro 1000000 / ;
-: nano  1000000000 / ;
-: pico  1000000000000 / ;
-: femto 1000000000000000 / ;
-: atto  1000000000000000000 / ;
-: zepto 1000000000000000000000 / ;
-: yocto 1000000000000000000000000 / ;
-
-: km kilo m ;
-: cm centi m ;
-: mm milli m ;
-: nm nano m ;
-: g milli kg ;
-: ms milli s ;
-: angstrom 10 / nm ;
+: yotta ( n -- x ) 1000000000000000000000000 * ;
+: zetta ( n -- x ) 1000000000000000000000 * ;
+: exa   ( n -- x ) 1000000000000000000 * ;
+: peta  ( n -- x ) 1000000000000000 * ;
+: tera  ( n -- x ) 1000000000000 * ;
+: giga  ( n -- x ) 1000000000 * ;
+: mega  ( n -- x ) 1000000 * ;
+: kilo  ( n -- x ) 1000 * ;
+: hecto ( n -- x ) 100 * ;
+: deca  ( n -- x ) 10 * ;
+: deci  ( n -- x ) 10 / ;
+: centi ( n -- x ) 100 / ;
+: milli ( n -- x ) 1000 / ;
+: micro ( n -- x ) 1000000 / ;
+: nano  ( n -- x ) 1000000000 / ;
+: pico  ( n -- x ) 1000000000000 / ;
+: femto ( n -- x ) 1000000000000000 / ;
+: atto  ( n -- x ) 1000000000000000000 / ;
+: zepto ( n -- x ) 1000000000000000000000 / ;
+: yocto ( n -- x ) 1000000000000000000000000 / ;
+
+: km ( n -- dimensioned ) kilo m ;
+: cm ( n -- dimensioned ) centi m ;
+: mm ( n -- dimensioned ) milli m ;
+: nm ( n -- dimensioned ) nano m ;
+: g ( n -- dimensioned ) milli kg ;
+: ms ( n -- dimensioned ) milli s ;
+: angstrom ( n -- dimensioned ) 10 / nm ;
index 32baf9e7ed3e27612c3e33752dd354672abe8aaa..f7330c14327b795324c2d0d7ba199d24e7ebd311 100755 (executable)
@@ -40,12 +40,12 @@ M: dimensions-not-equal summary drop "Dimensions do not match" ;
     [ dimensions 2array ] bi@ =
     [ dimensions-not-equal ] unless ;
 
-: 2values [ dimensioned-value ] bi@ ;
+: 2values ( dim dim -- val val ) [ dimensioned-value ] bi@ ;
 
-: <dimension-op
+: <dimension-op ( dim dim -- top bot val val )
     2dup check-dimensions dup dimensions 2swap 2values ;
 
-: dimension-op>
+: dimension-op> ( top bot val -- dim )
     -rot <dimensioned> ;
 
 : d+ ( d d -- d ) <dimension-op + dimension-op> ;
index 8c024ce7758db9444cb1f8164839062f992854f6..5942215a699b6473735d5288236b7a633a37a637 100644 (file)
@@ -2,27 +2,29 @@
 
 ! Thanks to Mackenzie Straight for the idea
 
-USING: compiler.units kernel parser words namespaces
-sequences quotations ;
+USING: kernel parser words namespaces sequences quotations ;
 
 IN: vars
 
-: define-var-symbol ( str -- ) create-in define-symbol ;
+: define-var-getter ( word -- )
+    [ word-name ">" append create-in ] [ [ get ] curry ] bi
+    (( -- value )) define-declared ;
 
-: define-var-getter ( str -- )
-dup ">" append create-in swap in get lookup [ get ] curry define ;
+: define-var-setter ( word -- )
+    [ word-name ">" prepend create-in ] [ [ set ] curry ] bi
+    (( value -- )) define-declared ;
 
-: define-var-setter ( str -- )
-">" over append create-in swap in get lookup [ set ] curry define ;
-
-: define-var ( str -- ) [
-dup define-var-symbol dup define-var-getter define-var-setter
-] with-compilation-unit ;
+: define-var ( str -- )
+    create-in
+    [ define-symbol ]
+    [ define-var-getter ]
+    [ define-var-setter ] tri ;
 
 : VAR: ! var
     scan define-var ; parsing
 
-: define-vars ( seq -- ) [ define-var ] each ;
+: define-vars ( seq -- )
+    [ define-var ] each ;
 
 : VARS: ! vars ...
-";" parse-tokens define-vars ; parsing
+    ";" parse-tokens define-vars ; parsing
index 60911b4947b663fade1b26e0df34c56359fa589f..8dbf7db6901ffafa7d29bc92c04974cde8a03de8 100644 (file)
@@ -50,7 +50,7 @@ M: post entity-url
 
 : <post> ( id -- post ) \ post new swap >>id ;
 
-: init-posts-table \ post ensure-table ;
+: init-posts-table ( -- ) \ post ensure-table ;
 
 TUPLE: comment < entity parent ;
 
@@ -69,7 +69,7 @@ M: comment entity-url
         swap >>id
         swap >>parent ;
 
-: init-comments-table comment ensure-table ;
+: init-comments-table ( -- ) comment ensure-table ;
 
 : post ( id -- post )
     [ <post> select-tuple ] [ f <comment> select-tuples ] bi
index d17a912ad81cb8afcb0074b2685914143631cd3f..f56a9b5c6f01a0f786bb4e392cb29f7668b90cec 100644 (file)
@@ -21,7 +21,7 @@ webapps.wee-url
 webapps.user-admin ;
 IN: webapps.factor-website
 
-: test-db "resource:test.db" sqlite-db ;
+: test-db ( -- db params ) "resource:test.db" sqlite-db ;
 
 : init-factor-db ( -- )
     test-db [
index 9e477d6156c5b277a37792ff3d8da8e69ba5d4ef..2fbe5b4816ce610a2b94007539759a8a0ce69d1c 100644 (file)
@@ -229,6 +229,6 @@ can-delete-pastes? define-capability
     <boilerplate>
         { pastebin "pastebin-common" } >>template ;
 
-: init-pastes-table \ paste ensure-table ;
+: init-pastes-table ( -- ) \ paste ensure-table ;
 
-: init-annotations-table annotation ensure-table ;
+: init-annotations-table ( -- ) annotation ensure-table ;
index 5af96cd4f717d83a2a9483b8cbcd4bebd4a9f669..3e780132b4e04cfc8ba096359f17f5ffb8bef243 100755 (executable)
@@ -45,9 +45,9 @@ posting "POSTINGS"
     { "date" "DATE" TIMESTAMP +not-null+ }
 } define-persistent
 
-: init-blog-table blog ensure-table ;
+: init-blog-table ( -- ) blog ensure-table ;
 
-: init-postings-table posting ensure-table ;
+: init-postings-table ( -- ) posting ensure-table ;
 
 : <blog> ( id -- todo )
     blog new
index a588b880d3cded941c1f8304cd8cbcdf9e726aa0..7cad1eb6ae960f29edb2e84295e7d3f61cdea810 100755 (executable)
@@ -28,7 +28,7 @@ todo "TODO"
     { "description" "DESCRIPTION" { VARCHAR 256 } }
 } define-persistent
 
-: init-todo-table todo ensure-table ;
+: init-todo-table ( -- ) todo ensure-table ;
 
 : <todo> ( id -- todo )
     todo new
index 1dc6ef4ae83486b79f0fd3f06137add1d1629aef..21a983fc7b4f6a51f918186b16a94f4a17d493e2 100644 (file)
@@ -43,7 +43,7 @@ article "ARTICLES" {
 
 : <article> ( title -- article ) article new swap >>title ;
 
-: init-articles-table article ensure-table ;
+: init-articles-table ( -- ) article ensure-table ;
 
 TUPLE: revision id title author date content ;
 
@@ -68,7 +68,7 @@ M: revision feed-entry-url id>> revision-url ;
 : <revision> ( id -- revision )
     revision new swap >>id ;
 
-: init-revisions-table revision ensure-table ;
+: init-revisions-table ( -- ) revision ensure-table ;
 
 : validate-title ( -- )
     { { "title" [ v-one-line ] } } validate-params ;
index 0d2f164c8de520244ae0fbcc039a208cec3a8acc..da0dfdb937bd560294d65a199f8e180ced2cc08a 100644 (file)
@@ -164,9 +164,9 @@ TYPEDEF: ACCESS_ALLOWED_CALLBACK_ACE* PACCESS_ALLOWED_CALLBACK_ACE
 : TOKEN_QUERY                  HEX: 0008 ; inline
 : TOKEN_QUERY_SOURCE           HEX: 0010 ; inline
 : TOKEN_ADJUST_DEFAULT         HEX: 0080 ; inline
-: TOKEN_READ STANDARD_RIGHTS_READ TOKEN_QUERY bitor ;
+: TOKEN_READ ( -- n ) STANDARD_RIGHTS_READ TOKEN_QUERY bitor ;
 
-: TOKEN_WRITE
+: TOKEN_WRITE ( -- n )
     {
         STANDARD_RIGHTS_WRITE
         TOKEN_ADJUST_PRIVILEGES
@@ -174,7 +174,7 @@ TYPEDEF: ACCESS_ALLOWED_CALLBACK_ACE* PACCESS_ALLOWED_CALLBACK_ACE
         TOKEN_ADJUST_DEFAULT
     } flags ; foldable
 
-: TOKEN_ALL_ACCESS
+: TOKEN_ALL_ACCESS ( -- n )
     {
         STANDARD_RIGHTS_REQUIRED
         TOKEN_ASSIGN_PRIMARY
@@ -336,7 +336,9 @@ FUNCTION: BOOL CryptAcquireContextW ( HCRYPTPROV* phProv,
                                       DWORD dwProvType,
                                       DWORD dwFlags ) ;
 
-: CryptAcquireContext CryptAcquireContextW ;
+: CryptAcquireContext ( phProv pszContainer pszProvider dwProvType dwFlags -- BOOL )
+    CryptAcquireContextW ;
+
 ! : CryptContextAddRef ;
 ! : CryptCreateHash ;
 ! : CryptDecrypt ;
@@ -496,7 +498,8 @@ FUNCTION: BOOL CryptReleaseContext ( HCRYPTPROV hProv, DWORD dwFlags ) ;
 
 ! : GetUserNameA ;
 FUNCTION: BOOL GetUserNameW ( LPCTSTR lpBuffer, LPDWORD lpnSize ) ;
-: GetUserName GetUserNameW ;
+: GetUserName ( lpBuffer lpnSize -- BOOL )
+    GetUserNameW ;
 
 ! : GetWindowsAccountDomainSid ;
 ! : I_ScIsSecurityProcess ;
@@ -541,7 +544,8 @@ FUNCTION: BOOL InitializeAcl ( PACL pAcl, DWORD nAclLength, DWORD dwAclRevision
 FUNCTION: BOOL LookupPrivilegeValueW ( LPCTSTR lpSystemName,
                                LPCTSTR lpName,
                                PLUID lpLuid ) ;
-: LookupPrivilegeValue LookupPrivilegeValueW ;
+: LookupPrivilegeValue ( lpSystemName lpname lpLuid -- BOOL )
+    LookupPrivilegeValueW ;
 
 ! : LookupSecurityDescriptorPartsA ;
 ! : LookupSecurityDescriptorPartsW ;
index 36f8b51e526460c85d36e0bc8ab819015d2613f4..277e69bccfb223a64f63984dcbc601e79b5ae0a5 100644 (file)
@@ -620,7 +620,7 @@ FUNCTION: HANDLE  CreateFileMappingW ( HANDLE hFile,
                                        DWORD dwMaximumSizeHigh,
                                        DWORD dwMaximumSizeLow,
                                        LPCTSTR lpName ) ;
-: CreateFileMapping CreateFileMappingW ;
+: CreateFileMapping ( hFile lpAttributes flProtect dwMaximumSizeHigh dwMaximumSizeLow lpName -- HANDLE ) CreateFileMappingW ;
 
 ! FUNCTION: CreateHardLinkA
 ! FUNCTION: CreateHardLinkW
@@ -636,7 +636,7 @@ FUNCTION: HANDLE CreateIoCompletionPort ( HANDLE hFileHandle, HANDLE hExistingCo
 ! FUNCTION: CreateMutexW
 ! FUNCTION: CreateNamedPipeA
 FUNCTION: HANDLE CreateNamedPipeW ( LPCTSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD nMaxInstances, DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES lpSecurityAttributes ) ;
-: CreateNamedPipe CreateNamedPipeW ;
+: CreateNamedPipe ( lpName dwOpenMode dwPipeMode nMaxInstances nOutBufferSize nInBufferSize nDefaultTimeOut lpSecurityAttributes -- HANDLE ) CreateNamedPipeW ;
 
 ! FUNCTION: CreateNlsSecurityDescriptor
 FUNCTION: BOOL CreatePipe ( PHANDLE hReadPipe, PHANDLE hWritePipe, LPSECURITY_ATTRIBUTES lpPipeAttributes, DWORD nSize ) ;
@@ -675,7 +675,7 @@ FUNCTION: BOOL CreateProcessW ( LPCTSTR lpApplicationname,
                                 LPCTSTR lpCurrentDirectory,
                                 LPSTARTUPINFO lpStartupInfo,
                                 LPPROCESS_INFORMATION lpProcessInformation ) ;
-: CreateProcess CreateProcessW ;
+: CreateProcess ( lpApplicationname lpCommandLine lpProcessAttributes lpThreadAttributes bInheritHandles dwCreationFlags lpEnvironment lpCurrentDirectory lpStartupInfo lpProcessInformation -- BOOL ) CreateProcessW ;
 ! FUNCTION: CreateProcessInternalA
 ! FUNCTION: CreateProcessInternalW
 ! FUNCTION: CreateProcessInternalWSecure
@@ -713,7 +713,7 @@ FUNCTION: HANDLE CreateRemoteThread ( HANDLE hProcess,
 ! FUNCTION: DeleteFiber
 ! FUNCTION: DeleteFileA
 FUNCTION: BOOL DeleteFileW ( LPCTSTR lpFileName ) ;
-: DeleteFile DeleteFileW ;
+: DeleteFile ( lpFileName -- BOOL ) DeleteFileW ;
 ! FUNCTION: DeleteTimerQueue
 ! FUNCTION: DeleteTimerQueueEx
 ! FUNCTION: DeleteTimerQueueTimer
@@ -804,12 +804,13 @@ FUNCTION: BOOL FindCloseChangeNotification ( HANDLE hChangeHandle ) ;
 FUNCTION: HANDLE FindFirstChangeNotificationW ( LPCTSTR lpPathName,
                                         BOOL bWatchSubtree,
                                         DWORD dwNotifyFilter ) ;
-: FindFirstChangeNotification FindFirstChangeNotificationW ;
+: FindFirstChangeNotification ( lpPathName bWatchSubtree dwNotifyFilter -- BOOL )
+    FindFirstChangeNotificationW ;
 ! FUNCTION: FindFirstFileA
 ! FUNCTION: FindFirstFileExA
 ! FUNCTION: FindFirstFileExW
 FUNCTION: HANDLE FindFirstFileW ( LPCTSTR lpFileName, LPWIN32_FIND_DATA lpFindFileData ) ;
-: FindFirstFile FindFirstFileW ;
+: FindFirstFile ( lpFileName lpFindFileData -- HANDLE ) FindFirstFileW ;
 ! FUNCTION: FindFirstVolumeA
 ! FUNCTION: FindFirstVolumeMountPointA
 ! FUNCTION: FindFirstVolumeMountPointW
@@ -817,7 +818,7 @@ FUNCTION: HANDLE FindFirstFileW ( LPCTSTR lpFileName, LPWIN32_FIND_DATA lpFindFi
 FUNCTION: BOOL FindNextChangeNotification ( HANDLE hChangeHandle ) ;
 ! FUNCTION: FindNextFileA
 FUNCTION: BOOL FindNextFileW ( HANDLE hFindFile, LPWIN32_FIND_DATA lpFindFileData ) ;
-: FindNextFile FindNextFileW ;
+: FindNextFile ( hFindFile lpFindFileData -- BOOL ) FindNextFileW ;
 ! FUNCTION: FindNextVolumeA
 ! FUNCTION: FindNextVolumeMountPointA
 ! FUNCTION: FindNextVolumeMountPointW
@@ -867,7 +868,7 @@ FUNCTION: BOOL FindNextFileW ( HANDLE hFindFile, LPWIN32_FIND_DATA lpFindFileDat
 FUNCTION: BOOL GetComputerNameW ( LPTSTR lpBuffer, LPDWORD lpnSize ) ;
 ! FUNCTION: GetComputerNameExW
 ! FUNCTION: GetComputerNameW
-: GetComputerName GetComputerNameW ;
+: GetComputerName ( lpBuffer lpnSize -- BOOL ) GetComputerNameW ;
 ! FUNCTION: GetConsoleAliasA
 ! FUNCTION: GetConsoleAliasesA
 ! FUNCTION: GetConsoleAliasesLengthA
@@ -902,7 +903,7 @@ FUNCTION: BOOL GetComputerNameW ( LPTSTR lpBuffer, LPDWORD lpnSize ) ;
 ! FUNCTION: GetConsoleScreenBufferInfo
 ! FUNCTION: GetConsoleSelectionInfo
 FUNCTION: DWORD GetConsoleTitleW ( LPWSTR lpConsoleTitle, DWORD nSize ) ;
-: GetConsoleTitle GetConsoleTitleW ; inline
+: GetConsoleTitle ( lpConsoleTitle nSize -- DWORD ) GetConsoleTitleW ; inline
 ! FUNCTION: GetConsoleWindow
 ! FUNCTION: GetCPFileNameFromRegistry
 ! FUNCTION: GetCPInfo
@@ -914,7 +915,7 @@ FUNCTION: DWORD GetConsoleTitleW ( LPWSTR lpConsoleTitle, DWORD nSize ) ;
 ! FUNCTION: GetCurrentConsoleFont
 ! FUNCTION: GetCurrentDirectoryA
 FUNCTION: BOOL GetCurrentDirectoryW ( DWORD len, LPTSTR buf ) ;
-: GetCurrentDirectory GetCurrentDirectoryW ; inline
+: GetCurrentDirectory ( len buf -- BOOL ) GetCurrentDirectoryW ; inline
 FUNCTION: HANDLE GetCurrentProcess ( ) ;
 FUNCTION: DWORD GetCurrentProcessId ( ) ;
 FUNCTION: HANDLE GetCurrentThread ( ) ;
@@ -951,7 +952,7 @@ FUNCTION: DWORD GetFileAttributesW ( LPCTSTR lpFileName ) ;
 
 FUNCTION: BOOL GetFileAttributesExW ( LPCTSTR lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, LPVOID lpFileInformation ) ;
 
-: GetFileAttributesEx GetFileAttributesExW ;
+: GetFileAttributesEx ( lpFileName fInfoLevelId lpFileInformation -- BOOL ) GetFileAttributesExW ;
 
 FUNCTION: BOOL GetFileInformationByHandle ( HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation ) ;
 FUNCTION: DWORD GetFileSize ( HANDLE hFile, LPDWORD lpFileSizeHigh ) ;
@@ -962,7 +963,7 @@ FUNCTION: DWORD GetFileType ( HANDLE hFile ) ;
 ! FUNCTION: GetFirmwareEnvironmentVariableW
 ! FUNCTION: GetFullPathNameA
 FUNCTION: DWORD GetFullPathNameW ( LPCTSTR lpFileName, DWORD nBufferLength, LPTSTR lpBuffer, LPTSTR* lpFilePart ) ;
-: GetFullPathName GetFullPathNameW ;
+: GetFullPathName ( lpFileName nBufferLength lpBuffer lpFilePart -- DWORD ) GetFullPathNameW ;
 
 !  clear "license.txt" 32768 "char[32768]" <c-object> f over >r GetFullPathName r> swap 2 * head >string .
 
@@ -985,7 +986,7 @@ FUNCTION: DWORD GetLastError ( ) ;
 ! FUNCTION: GetModuleFileNameA
 ! FUNCTION: GetModuleFileNameW
 FUNCTION: HMODULE GetModuleHandleW ( LPCWSTR lpModuleName ) ;
-: GetModuleHandle GetModuleHandleW ; inline
+: GetModuleHandle ( lpModuleName -- HMODULE ) GetModuleHandleW ; inline
 ! FUNCTION: GetModuleHandleExA
 ! FUNCTION: GetModuleHandleExW
 ! FUNCTION: GetNamedPipeHandleStateA
@@ -1051,7 +1052,7 @@ FUNCTION: HANDLE GetStdHandle ( DWORD nStdHandle ) ;
 ! FUNCTION: GetSystemDefaultUILanguage
 ! FUNCTION: GetSystemDirectoryA
 FUNCTION: UINT GetSystemDirectoryW ( LPTSTR lpBuffer, UINT uSize ) ;
-: GetSystemDirectory GetSystemDirectoryW ; inline
+: GetSystemDirectory ( lpBuffer uSize -- UINT ) GetSystemDirectoryW ; inline
 FUNCTION: void GetSystemInfo ( LPSYSTEM_INFO lpSystemInfo ) ;
 ! FUNCTION: GetSystemPowerStatus
 ! FUNCTION: GetSystemRegistryQuota
@@ -1061,7 +1062,7 @@ FUNCTION: void GetSystemTimeAsFileTime ( LPFILETIME lpSystemTimeAsFileTime ) ;
 ! FUNCTION: GetSystemTimes
 ! FUNCTION: GetSystemWindowsDirectoryA
 FUNCTION: UINT GetSystemWindowsDirectoryW ( LPTSTR lpBuffer, UINT uSize ) ;
-: GetSystemWindowsDirectory GetSystemWindowsDirectoryW ; inline
+: GetSystemWindowsDirectory ( lpBuffer uSize -- UINT ) GetSystemWindowsDirectoryW ; inline
 ! FUNCTION: GetSystemWow64DirectoryA
 ! FUNCTION: GetSystemWow64DirectoryW
 ! FUNCTION: GetTapeParameters
@@ -1089,7 +1090,7 @@ FUNCTION: DWORD GetTimeZoneInformation ( LPTIME_ZONE_INFORMATION lpTimeZoneInfor
 ! FUNCTION: GetVDMCurrentDirectories
 FUNCTION: DWORD GetVersion ( ) ;
 FUNCTION: BOOL GetVersionExW ( LPOSVERSIONINFO lpVersionInfo ) ;
-: GetVersionEx GetVersionExW ;
+: GetVersionEx ( lpVersionInfo -- BOOL ) GetVersionExW ;
 ! FUNCTION: GetVolumeInformationA
 ! FUNCTION: GetVolumeInformationW
 ! FUNCTION: GetVolumeNameForVolumeMountPointA
@@ -1100,7 +1101,7 @@ FUNCTION: BOOL GetVersionExW ( LPOSVERSIONINFO lpVersionInfo ) ;
 ! FUNCTION: GetVolumePathNameW
 ! FUNCTION: GetWindowsDirectoryA
 FUNCTION: UINT GetWindowsDirectoryW ( LPTSTR lpBuffer, UINT uSize ) ;
-: GetWindowsDirectory GetWindowsDirectoryW ; inline
+: GetWindowsDirectory ( lpBuffer uSize -- UINT ) GetWindowsDirectoryW ; inline
 ! FUNCTION: GetWriteWatch
 ! FUNCTION: GlobalAddAtomA
 ! FUNCTION: GlobalAddAtomW
@@ -1252,7 +1253,7 @@ FUNCTION: LPVOID MapViewOfFileEx ( HANDLE hFileMappingObject,
 ! FUNCTION: MoveFileExA
 ! FUNCTION: MoveFileExW
 FUNCTION: BOOL MoveFileW ( LPCTSTR lpExistingFileName, LPCTSTR lpNewFileName ) ;
-: MoveFile MoveFileW ;
+: MoveFile ( lpExistingFileName lpNewFileName -- BOOL ) MoveFileW ;
 ! FUNCTION: MoveFileWithProgressA
 ! FUNCTION: MoveFileWithProgressW
 ! FUNCTION: MulDiv
@@ -1270,7 +1271,7 @@ FUNCTION: BOOL MoveFileW ( LPCTSTR lpExistingFileName, LPCTSTR lpNewFileName ) ;
 FUNCTION: HANDLE OpenFileMappingW ( DWORD dwDesiredAccess,
                                     BOOL bInheritHandle,
                                     LPCTSTR lpName ) ;
-: OpenFileMapping OpenFileMappingW ;
+: OpenFileMapping ( dwDesiredAccess bInheritHandle lpName -- HANDLE ) OpenFileMappingW ;
 ! FUNCTION: OpenJobObjectA
 ! FUNCTION: OpenJobObjectW
 ! FUNCTION: OpenMutexA
@@ -1340,7 +1341,7 @@ FUNCTION: BOOL ReadProcessMemory ( HANDLE hProcess, void* lpBaseAddress, void* l
 ! FUNCTION: ReleaseSemaphore
 ! FUNCTION: RemoveDirectoryA
 FUNCTION: BOOL RemoveDirectoryW ( LPCTSTR lpPathName ) ;
-: RemoveDirectory RemoveDirectoryW ;
+: RemoveDirectory ( lpPathName -- BOOL ) RemoveDirectoryW ;
 ! FUNCTION: RemoveLocalAlternateComputerNameA
 ! FUNCTION: RemoveLocalAlternateComputerNameW
 ! FUNCTION: RemoveVectoredExceptionHandler
@@ -1404,13 +1405,13 @@ FUNCTION: BOOL RemoveDirectoryW ( LPCTSTR lpPathName ) ;
 ! FUNCTION: SetConsoleScreenBufferSize
 FUNCTION: BOOL SetConsoleTextAttribute ( HANDLE hConsoleOutput, WORD wAttributes ) ;
 FUNCTION: BOOL SetConsoleTitleW ( LPCWSTR lpConsoleTitle ) ;
-: SetConsoleTitle SetConsoleTitleW ;
+: SetConsoleTitle ( lpConsoleTitle -- BOOL ) SetConsoleTitleW ;
 ! FUNCTION: SetConsoleWindowInfo
 ! FUNCTION: SetCPGlobal
 ! FUNCTION: SetCriticalSectionSpinCount
 ! FUNCTION: SetCurrentDirectoryA
 FUNCTION: BOOL SetCurrentDirectoryW ( LPCWSTR lpDirectory ) ;
-: SetCurrentDirectory SetCurrentDirectoryW ; inline
+: SetCurrentDirectory ( lpDirectory -- BOOL ) SetCurrentDirectoryW ; inline
 ! FUNCTION: SetDefaultCommConfigA
 ! FUNCTION: SetDefaultCommConfigW
 ! FUNCTION: SetDllDirectoryA
index 3e7520d4063a33a23b3399813ad071328d32dd64..2fc1dbf12207a86d857c20c27046d94a93f01b62 100644 (file)
@@ -40,7 +40,7 @@ FUNCTION: void* error_message ( DWORD id ) ;
         win32-error-string throw
     ] when ;
 
-: expected-io-errors
+: expected-io-errors ( -- seq )
     ERROR_SUCCESS
     ERROR_IO_INCOMPLETE
     ERROR_IO_PENDING
index 9e1e0ef92021c149d717b7fab8793e0f74812ead..cbe3c633fc54185135d768ebba3f73863007c7e3 100755 (executable)
@@ -8,9 +8,9 @@ IN: x11.clipboard
 ! This code was based on by McCLIM's Backends/CLX/port.lisp
 ! and http://common-lisp.net/~crhodes/clx/demo/clipboard.lisp.
 
-: XA_CLIPBOARD "CLIPBOARD" x-atom ;
+: XA_CLIPBOARD ( -- atom ) "CLIPBOARD" x-atom ;
 
-: XA_UTF8_STRING "UTF8_STRING" x-atom ;
+: XA_UTF8_STRING ( -- atom ) "UTF8_STRING" x-atom ;
 
 TUPLE: x-clipboard atom contents ;
 
index 5781fdc806a646a55cb2c409f219b35d38fb2d15..fcce09380fdd2deeb44b000b8900430e6a98d717 100644 (file)
@@ -45,7 +45,7 @@ TYPEDEF: uchar KeyCode
 ! with button names below.
 
 
-: AnyModifier           1 15 shift ; ! used in GrabButton, GrabKey
+: AnyModifier          ( -- n ) 15 2^ ; ! used in GrabButton, GrabKey
 
 ! button names. Used as arguments to GrabButton and as detail in ButtonPress
 ! and ButtonRelease events.  Not to be confused with button masks above.
@@ -128,8 +128,8 @@ TYPEDEF: uchar KeyCode
 
 ! Used in SetInputFocus, GetInputFocus
 
-: RevertToNone          None ;
-: RevertToPointerRoot   PointerRoot ;
+: RevertToNone         ( -- n ) None ;
+: RevertToPointerRoot  ( -- n ) PointerRoot ;
 : RevertToParent        2 ;
 
 ! *****************************************************************
@@ -307,9 +307,9 @@ TYPEDEF: uchar KeyCode
 
 ! Flags used in StoreNamedColor, StoreColors
 
-: DoRed         1 0 shift ;
-: DoGreen       1 1 shift ;
-: DoBlue        1 2 shift ;
+: DoRed        ( -- n ) 0 2^ ;
+: DoGreen      ( -- n ) 1 2^ ;
+: DoBlue       ( -- n ) 2 2^ ;
 
 ! *****************************************************************
 ! * CURSOR STUFF
@@ -334,14 +334,14 @@ TYPEDEF: uchar KeyCode
 
 ! masks for ChangeKeyboardControl
 
-: KBKeyClickPercent     1 0 shift ;
-: KBBellPercent         1 1 shift ;
-: KBBellPitch           1 2 shift ;
-: KBBellDuration        1 3 shift ;
-: KBLed                 1 4 shift ;
-: KBLedMode             1 5 shift ;
-: KBKey                 1 6 shift ;
-: KBAutoRepeatMode      1 7 shift ;
+: KBKeyClickPercent    ( -- n ) 0 2^ ;
+: KBBellPercent        ( -- n ) 1 2^ ;
+: KBBellPitch          ( -- n ) 2 2^ ;
+: KBBellDuration       ( -- n ) 3 2^ ;
+: KBLed                ( -- n ) 4 2^ ;
+: KBLedMode            ( -- n ) 5 2^ ;
+: KBKey                ( -- n ) 6 2^ ;
+: KBAutoRepeatMode     ( -- n ) 7 2^ ;
 
 : MappingSuccess        0 ;
 : MappingBusy           1 ;
index 154bf4d6ffe196dfb8d67017f1db2cb4b37a8d62..3c0ae24a70d8fdab7653a4a7870b854e534a2c81 100755 (executable)
@@ -1079,17 +1079,17 @@ FUNCTION: Status XWithdrawWindow (
 
 ! 17.1.7 - Setting and Reading the WM_NORMAL_HINTS Property
 
-: USPosition    1 0 shift ; inline
-: USSize        1 1 shift ; inline
-: PPosition     1 2 shift ; inline
-: PSize         1 3 shift ; inline
-: PMinSize      1 4 shift ; inline
-: PMaxSize      1 5 shift ; inline
-: PResizeInc    1 6 shift ; inline
-: PAspect       1 7 shift ; inline
-: PBaseSize     1 8 shift ; inline
-: PWinGravity   1 9 shift ; inline
-: PAllHints 
+: USPosition   ( -- n ) 0 2^ ; inline
+: USSize       ( -- n ) 1 2^ ; inline
+: PPosition    ( -- n ) 2 2^ ; inline
+: PSize        ( -- n ) 3 2^ ; inline
+: PMinSize     ( -- n ) 4 2^ ; inline
+: PMaxSize     ( -- n ) 5 2^ ; inline
+: PResizeInc   ( -- n ) 6 2^ ; inline
+: PAspect      ( -- n ) 7 2^ ; inline
+: PBaseSize    ( -- n ) 8 2^ ; inline
+: PWinGravity  ( -- n ) 9 2^ ; inline
+: PAllHints    ( -- n )
     { PPosition PSize PMinSize PMaxSize PResizeInc PAspect } flags ; foldable
 
 C-STRUCT: XSizeHints
@@ -1366,7 +1366,7 @@ SYMBOL: root
 
 : x-atom ( string -- atom ) dpy get swap 0 XInternAtom ;
 
-: check-display
+: check-display ( alien -- alien' )
     [
         "Cannot connect to X server - check $DISPLAY" throw
     ] unless* ;
index 53f2046a544c77019cbc2c03ad56078e417ac3dc..58c27cabe7cdf088c88327ae147412e8bed08b27 100644 (file)
@@ -40,7 +40,7 @@ M: xml-string-error summary ( obj -- str )
     ] with-string-writer ;
 
 TUPLE: mismatched < parsing-error open close ;
-: <mismatched>
+: <mismatched> ( open close -- error )
     \ mismatched parsing-error swap >>close swap >>open ;
 M: mismatched summary ( obj -- str )
     [
@@ -111,7 +111,7 @@ M: extra-attrs summary ( obj -- str )
     ] with-string-writer ;
 
 TUPLE: bad-version < parsing-error num ;
-: <bad-version>
+: <bad-version> ( num -- error )
     \ bad-version parsing-error swap >>num ;
 M: bad-version summary ( obj -- str )
     [
index f78620986562f70ae993a7548ca09377194825a7..6a9913b35e86af38e7104796993c75317791a1f7 100644 (file)
@@ -1,5 +1,5 @@
-USING: kernel strings assocs sequences hashtables sorting
-       unicode.case unicode.categories sets ;
+USING: accessors kernel strings assocs sequences hashtables
+sorting unicode.case unicode.categories sets ;
 IN: xmode.keyword-map
 
 ! Based on org.gjt.sp.jedit.syntax.KeywordMap
@@ -9,7 +9,7 @@ TUPLE: keyword-map no-word-sep ignore-case? ;
     H{ } clone { set-keyword-map-ignore-case? set-delegate }
     keyword-map construct ;
 
-: invalid-no-word-sep f swap set-keyword-map-no-word-sep ;
+: invalid-no-word-sep ( keyword-map -- ) f >>no-word-sep drop ;
 
 : handle-case ( key keyword-map -- key assoc )
     [ keyword-map-ignore-case? [ >upper ] when ] keep
@@ -25,7 +25,7 @@ M: keyword-map clear-assoc
 
 M: keyword-map >alist delegate >alist ;
 
-: (keyword-map-no-word-sep)
+: (keyword-map-no-word-sep) ( assoc -- str )
     keys concat [ alpha? not ] filter prune natural-sort ;
 
 : keyword-map-no-word-sep* ( keyword-map -- str )
index 68b2c85a7db0207e704d0f7ecb42b52e97993406..5cf367594136a5afa7d57f9ef8a23f8a7b434932 100755 (executable)
@@ -49,7 +49,8 @@ TAG: KEYWORDS ( rule-set tag -- key value )
 
 TAGS>
 
-: ?<regexp> dup [ ignore-case? get <regexp> ] when ;
+: ?<regexp> ( string/f -- regexp/f )
+    dup [ ignore-case? get <regexp> ] when ;
 
 : (parse-rules-tag) ( tag -- rule-set )
     <rule-set>
index c754db61c86725adede478261124f87be1eab965..175c8ed22f2dff2ea652c5781899eeb38288e7a4 100644 (file)
@@ -24,7 +24,7 @@ SYMBOL: ignore-case?
         [ string>token ]
     } case ;
 
-: string>rule-set-name "MAIN" or ;
+: string>rule-set-name ( string -- name ) "MAIN" or ;
 
 ! PROP, PROPS
 : parse-prop-tag ( tag -- key value )
@@ -48,30 +48,30 @@ SYMBOL: ignore-case?
     dup children>string ignore-case? get <regexp>
     swap position-attrs <matcher> ;
 
-: shared-tag-attrs
+: shared-tag-attrs ( -- )
     { "TYPE" string>token set-rule-body-token } , ; inline
 
-: delegate-attr
+: delegate-attr ( -- )
     { "DELEGATE" f set-rule-delegate } , ;
 
-: regexp-attr
+: regexp-attr ( -- )
     { "HASH_CHAR" f set-rule-chars } , ;
 
-: match-type-attr
+: match-type-attr ( -- )
     { "MATCH_TYPE" string>match-type set-rule-match-token } , ;
 
-: span-attrs
+: span-attrs ( -- )
     { "NO_LINE_BREAK" string>boolean set-rule-no-line-break? } ,
     { "NO_WORD_BREAK" string>boolean set-rule-no-word-break? } ,
     { "NO_ESCAPE" string>boolean set-rule-no-escape? } , ;
 
-: literal-start
+: literal-start ( -- )
     [ parse-literal-matcher swap set-rule-start ] , ;
 
-: regexp-start
+: regexp-start ( -- )
     [ parse-regexp-matcher swap set-rule-start ] , ;
 
-: literal-end
+: literal-end ( -- )
     [ parse-literal-matcher swap set-rule-end ] , ;
 
 ! SPAN's children
@@ -87,15 +87,15 @@ TAG: END
 
 TAGS>
 
-: parse-begin/end-tags
+: parse-begin/end-tags ( -- )
     [
         ! XXX: handle position attrs on span tag itself
         child-tags [ parse-begin/end-tag ] with each
     ] , ;
 
-: init-span-tag [ drop init-span ] , ;
+: init-span-tag ( -- ) [ drop init-span ] , ;
 
-: init-eol-span-tag [ drop init-eol-span ] , ;
+: init-eol-span-tag ( -- ) [ drop init-eol-span ] , ;
 
 : parse-keyword-tag ( tag keyword-map -- )
     >r dup name-tag string>token swap children>string r> set-at ;
index 91ccd43907affbda8e222ef0357e6cd1b23f6386..a921e6a022b79f62b2d04ba25c9027280559415b 100755 (executable)
@@ -189,7 +189,7 @@ M: mark-previous-rule handle-rule-start
     dup rule-body-token prev-token,
     rule-match-token* next-token, ;
 
-: do-escaped
+: do-escaped ( -- )
     escaped? get [
         escaped? off
         ! ...
index db59465b7b559e937e5aa5585821d5d55945cc72..0321974c9ed6edd585821058d07bd87cb3b74330 100644 (file)
@@ -45,7 +45,7 @@ SYMBOL: tag-handler-word
     CREATE tag-handler-word set
     H{ } clone tag-handlers set ; parsing
 
-: (TAG:) swap tag-handlers get set-at ;
+: (TAG:) ( name quot -- ) swap tag-handlers get set-at ;
 
 : TAG:
     f set-word
@@ -55,4 +55,4 @@ SYMBOL: tag-handler-word
 : TAGS>
     tag-handler-word get
     tag-handlers get >alist [ >r dup name-tag r> case ] curry
-    define ; parsing
+    (( tag -- )) define-declared ; parsing