]> gitweb.factorcode.org Git - factor.git/commitdiff
Fixing compile errors, test failures and help lint failures
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Mon, 23 Mar 2009 22:12:41 +0000 (17:12 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Mon, 23 Mar 2009 22:12:41 +0000 (17:12 -0500)
39 files changed:
basis/grouping/grouping-docs.factor
basis/help/cookbook/cookbook.factor
basis/lists/lazy/lazy-docs.factor
basis/lists/lazy/lazy.factor
basis/math/bitwise/bitwise-docs.factor
basis/memoize/memoize-docs.factor
basis/promises/authors.txt [new file with mode: 0644]
basis/promises/promises-docs.factor [new file with mode: 0755]
basis/promises/promises-tests.factor [new file with mode: 0644]
basis/promises/promises.factor [new file with mode: 0755]
basis/promises/summary.txt [new file with mode: 0644]
basis/promises/tags.txt [new file with mode: 0644]
basis/refs/refs-docs.factor
basis/refs/refs.factor
basis/see/see-docs.factor
basis/stack-checker/stack-checker-docs.factor
basis/stack-checker/stack-checker-tests.factor
basis/ui/commands/commands-docs.factor
core/math/math-docs.factor
core/memory/memory-tests.factor
core/strings/strings-docs.factor
core/strings/strings.factor
core/syntax/syntax-docs.factor
core/words/words-docs.factor
extra/24-game/24-game.factor
extra/animations/animations-docs.factor
extra/animations/animations.factor
extra/ctags/ctags-docs.factor
extra/ctags/ctags.factor
extra/literals/literals-docs.factor
extra/multi-methods/multi-methods.factor
extra/newfx/newfx.factor
extra/promises/authors.txt [deleted file]
extra/promises/promises-docs.factor [deleted file]
extra/promises/promises-tests.factor [deleted file]
extra/promises/promises.factor [deleted file]
extra/promises/summary.txt [deleted file]
extra/promises/tags.txt [deleted file]
extra/sequences/n-based/n-based-docs.factor

index e4ad97abd0c7a3a33c3f157d5ee0f25ee432284b..50ffa65474c839a0aa71dde94741b0bcfff58a3c 100644 (file)
@@ -97,8 +97,7 @@ HELP: <clumps>
     { $example
         "USING: grouping sequences math prettyprint kernel ;"
         "IN: scratchpad"
-        ": share-price"
-        "    { 13/50 51/100 13/50 1/10 4/5 17/20 33/50 3/25 19/100 3/100 } ;"
+        "CONSTANT: share-price { 13/50 51/100 13/50 1/10 4/5 17/20 33/50 3/25 19/100 3/100 }"
         ""
         "share-price 4 <clumps> [ [ sum ] [ length ] bi / ] map ."
         "{ 113/400 167/400 201/400 241/400 243/400 91/200 1/4 }"
index d6693cd94f823d1339abd117e1e14d4993f98940..2cc19f87ddc2f857760aa68bec6d6ac1db57f8b8 100644 (file)
@@ -121,16 +121,16 @@ $nl
     "sequences"
 } ;
 
-ARTICLE: "cookbook-variables" "Variables cookbook"
-"Before using a variable, you must define a symbol for it:"
-{ $code "SYMBOL: name" }
+ARTICLE: "cookbook-variables" "Dynamic variables cookbook"
 "A symbol is a word which pushes itself on the stack when executed. Try it:"
 { $example "SYMBOL: foo" "foo ." "foo" }
+"Before using a variable, you must define a symbol for it:"
+{ $code "SYMBOL: name" }
 "Symbols can be passed to the " { $link get } " and " { $link set } " words to read and write variable values:"
-{ $example "\"Slava\" name set" "name get print" "Slava" }
+{ $unchecked-example "\"Slava\" name set" "name get print" "Slava" }
 "If you set variables inside a " { $link with-scope } ", their values will be lost after leaving the scope:"
-{ $example
-    ": print-name name get print ;"
+{ $unchecked-example
+    ": print-name ( -- ) name get print ;"
     "\"Slava\" name set"
     "["
     "    \"Diana\" name set"
@@ -139,11 +139,8 @@ ARTICLE: "cookbook-variables" "Variables cookbook"
     "\"Here, the name is \" write  print-name"
     "There, the name is Diana\nHere, the name is Slava"
 }
-{ $curious
-    "Variables are dynamically-scoped in Factor."
-}
 { $references
-    "There is a lot more to be said about variables and namespaces."
+    "There is a lot more to be said about dynamically-scoped variables and namespaces."
     "namespaces"
 } ;
 
index 08fe3bbcba543fa711a487739daa45b7c5cd9380..c46d3251a94f34ee201cc594a0ed1bd8c80e3070 100644 (file)
@@ -108,7 +108,7 @@ HELP: lappend
 { $description "Perform a similar functionality to that of the " { $link append } " word, but in a lazy manner. No evaluation of the list elements occurs initially but a " { $link <lazy-append> } " object is returned which conforms to the list protocol. Calling " { $link car } ", " { $link cdr } " or " { $link nil? } " on this will evaluate elements as required. Successive calls to " { $link cdr } " will iterate through list1, followed by list2." } ;
 
 HELP: lfrom-by
-{ $values { "n" "an integer" } { "quot" { $quotation "( -- int )" } } { "list" "a lazy list of integers" } }
+{ $values { "n" "an integer" } { "quot" { $quotation "( -- int )" } } { "lazy-from-by" "a lazy list of integers" } }
 { $description "Return an infinite lazy list of values starting from n, with each successive value being the result of applying quot to n." } ;
 
 HELP: lfrom
index 139f6726e8bc61c419abcfb03b204b8c3de2522e..64a3f099a0ed5056ecfe327aa3482fa38dc4e905 100644 (file)
@@ -203,7 +203,7 @@ M: lazy-append nil? ( lazy-append -- bool )
 
 TUPLE: lazy-from-by n quot ;
 
-C: lfrom-by lazy-from-by ( n quot -- list )
+C: lfrom-by lazy-from-by
 
 : lfrom ( n -- list )
     [ 1+ ] lfrom-by ;
index 358c984276665182a774815dfec360c41151af06..fca06526e0501eb6c5665dfa264c169d4b5fa783 100644 (file)
@@ -139,8 +139,8 @@ HELP: flags
 { $examples
     { $example "USING: math.bitwise kernel prettyprint ;"
         "IN: scratchpad"
-        ": MY-CONSTANT HEX: 1 ; inline"
-        "{ HEX: 20 MY-CONSTANT BIN: 100 } flags .h"
+        "CONSTANT: x HEX: 1"
+        "{ HEX: 20 x BIN: 100 } flags .h"
         "25"
     }
 } ;
index a6f78970c8ddeaa6e5518952bd48b58fe5b93ec6..cfb5cffb37ad38f07f372a01a80324bb485e7a87 100644 (file)
@@ -1,10 +1,10 @@
-! Copyright (C) 2007 Slava Pestov, Daniel Ehrenberg.
+! Copyright (C) 2007, 2009 Slava Pestov, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: help.syntax help.markup ;
+USING: help.syntax help.markup words quotations effects ;
 IN: memoize
 
 HELP: define-memoized
-{ $values { "word" "the word to be defined" } { "quot" "a quotation" } }
+{ $values { "word" word } { "quot" quotation } { "effect" effect } }
 { $description "defines the given word at runtime as one which memoizes its output given a particular input" }
 { $notes "A maximum of four input and four output arguments can be used" }
 { $see-also POSTPONE: MEMO: } ;
diff --git a/basis/promises/authors.txt b/basis/promises/authors.txt
new file mode 100644 (file)
index 0000000..44b06f9
--- /dev/null
@@ -0,0 +1 @@
+Chris Double
diff --git a/basis/promises/promises-docs.factor b/basis/promises/promises-docs.factor
new file mode 100755 (executable)
index 0000000..d416842
--- /dev/null
@@ -0,0 +1,20 @@
+! Copyright (C) 2006 Chris Double.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax ;
+IN: promises
+
+HELP: promise 
+{ $values { "quot" { $quotation "( -- X )" } } { "promise" "a promise object" } }
+{ $description "Creates a promise to return a value. When forced this quotation is called and the value returned. The value is memorised so that calling " { $link force } " again does not call the quotation again, instead the previous value is returned directly." } ;
+
+HELP: force
+{ $values { "promise" "a promise object" } { "value" "a factor object" } }
+{ $description "Calls the quotation associated with the promise if it has not been called before, and returns the value. If the promise has been forced previously, returns the value from the previous call." } ;
+
+HELP: LAZY:
+{ $syntax "LAZY: word ( stack -- effect ) definition... ;" } 
+{ $values { "word" "a new word to define" } { "definition" "a word definition" } }
+{ $description "Creates a lazy word in the current vocabulary. When executed the word will return a " { $link promise } " that when forced, executes the word definition. Any values on the stack that are required by the word definition are captured along with the promise." } 
+{ $examples
+  { $example "USING: arrays sequences prettyprint promises ;" "IN: scratchpad" "LAZY: zeroes ( -- pair ) 0 zeroes 2array ;" "zeroes force second force first ." "0" }
+} ;
diff --git a/basis/promises/promises-tests.factor b/basis/promises/promises-tests.factor
new file mode 100644 (file)
index 0000000..79e7dc5
--- /dev/null
@@ -0,0 +1,7 @@
+IN: promises.tests
+USING: promises math tools.test ;
+
+LAZY: lazy-test ( a -- b ) 1 + ;
+
+{ 1 1 } [ lazy-test ] must-infer-as
+[ 3 ] [ 2 lazy-test force ] unit-test
\ No newline at end of file
diff --git a/basis/promises/promises.factor b/basis/promises/promises.factor
new file mode 100755 (executable)
index 0000000..c3951f4
--- /dev/null
@@ -0,0 +1,22 @@
+! Copyright (C) 2004, 2006 Chris Double, Matthew Willis.
+! See http://factorcode.org/license.txt for BSD license.
+USING: arrays kernel sequences math arrays namespaces
+parser effects generalizations fry words accessors ;
+IN: promises
+
+TUPLE: promise quot forced? value ;
+
+: promise ( quot -- promise ) f f \ promise boa ;
+
+: force ( promise -- value )
+    dup forced?>> [
+        dup quot>> call( -- value ) >>value
+        t >>forced?
+    ] unless
+    value>> ;
+
+: make-lazy-quot ( quot effect -- quot )
+    in>> length '[ _ _ ncurry promise ] ;
+
+SYNTAX: LAZY:
+    (:) [ make-lazy-quot ] [ 2nip ] 3bi define-declared ;
diff --git a/basis/promises/summary.txt b/basis/promises/summary.txt
new file mode 100644 (file)
index 0000000..d64fe20
--- /dev/null
@@ -0,0 +1 @@
+Lazy thunks
diff --git a/basis/promises/tags.txt b/basis/promises/tags.txt
new file mode 100644 (file)
index 0000000..f427429
--- /dev/null
@@ -0,0 +1 @@
+extensions
index b6f222cce98c6062f8f1da3d2c2b5f43fd729f4e..a219f0ba8b24cfcb6f21e5ffef844c2c099a3e20 100644 (file)
@@ -37,14 +37,14 @@ HELP: key-ref
 { $class-description "Instances of this class identify a key in an associative structure. New key references are created by calling " { $link <key-ref> } "." } ;
 
 HELP: <key-ref>
-{ $values { "key" object } { "assoc" "an assoc" } { "ref" key-ref } }
+{ $values { "assoc" "an assoc" } { "key" object } { "key-ref" key-ref } }
 { $description "Creates a reference to a key stored in an assoc." } ;
 
 HELP: value-ref
 { $class-description "Instances of this class identify a value associated to a key in an associative structure. New value references are created by calling " { $link <value-ref> } "." } ;
 
 HELP: <value-ref>
-{ $values { "key" object } { "assoc" "an assoc" } { "ref" value-ref } }
+{ $values { "assoc" "an assoc" } { "key" object } { "value-ref" value-ref } }
 { $description "Creates a reference to the value associated with " { $snippet "key" } " in " { $snippet "assoc" } "." } ;
 
 { get-ref set-ref delete-ref } related-words
index 5f21dad7760c2dd91d153adcc6ca895016df9ab5..0164a1ea57872c3b5c33ca25056af2cffd542fc7 100644 (file)
@@ -12,11 +12,11 @@ GENERIC: get-ref ( ref -- obj )
 GENERIC: set-ref ( obj ref -- )
 
 TUPLE: key-ref < ref ;
-C: <key-ref> key-ref ( assoc key -- ref )
+C: <key-ref> key-ref
 M: key-ref get-ref key>> ;
 M: key-ref set-ref >ref< rename-at ;
 
 TUPLE: value-ref < ref ;
-C: <value-ref> value-ref ( assoc key -- ref )
+C: <value-ref> value-ref
 M: value-ref get-ref >ref< at ;
 M: value-ref set-ref >ref< set-at ;
index 755d4ac9bc647307346b07e7416bc0fb167d8800..cea2592bc2fffde960e9edbdb9ee3d9308955531 100644 (file)
@@ -25,7 +25,7 @@ HELP: definer
 { $examples
     { $example "USING: definitions prettyprint ;"
                "IN: scratchpad"
-               ": foo ; \\ foo definer . ."
+               ": foo ( -- ) ; \\ foo definer . ."
                ";\nPOSTPONE: :"
     }
     { $example "USING: definitions prettyprint ;"
index 088fab34d0249db028810cf1f0f49c5323bec839..28090918bbc7aec7f5a6db11768226beaba964f5 100644 (file)
@@ -33,9 +33,9 @@ $nl
 "A general rule of thumb is that any word which applies " { $link call } " or " { $link curry } " to one of its inputs must be declared " { $link POSTPONE: inline } "."
 $nl
 "Here is an example where the stack effect cannot be inferred:"
-{ $code ": foo 0 [ + ] ;" "[ foo reduce ] infer." }
+{ $code ": foo ( -- n quot ) 0 [ + ] ;" "[ foo reduce ] infer." }
 "However if " { $snippet "foo" } " was declared " { $link POSTPONE: inline } ", everything would work, since the " { $link reduce } " combinator is also " { $link POSTPONE: inline } ", and the inferencer can see the literal quotation value at the point it is passed to " { $link call } ":"
-{ $example ": foo 0 [ + ] ; inline" "[ foo reduce ] infer." "( object -- object )" }
+{ $example ": foo ( -- n quot ) 0 [ + ] ; inline" "[ foo reduce ] infer." "( object -- object )" }
 "Passing a literal quotation on the data stack through an inlined recursive combinator nullifies its literal status. For example, the following will not infer:"
 { $example
   "[ [ reverse ] swap [ reverse ] map swap call ] infer." "Got a computed value where a literal quotation was expected\n\nType :help for debugging help."
index 3d8c2cdd8c24ea87f9deddd3429334f4a31f3f60..117b6845b8847e683014a6eec4e2ce1e9965c206 100644 (file)
@@ -292,7 +292,7 @@ DEFER: bar
 
 [ [ [ m ] m ] infer ] [ inference-error? ] must-fail-with
 
-: m' dup curry call ; inline
+: m' ( quot -- ) dup curry call ; inline
 
 [ [ [ m' ] m' ] infer ] [ inference-error? ] must-fail-with
 
index 81a4096aab82ee4c08a2eaa4c72e7ff22bc4353b..b576f173b6fc1e5c1f785d46498d4a3c35acc770 100644 (file)
@@ -54,7 +54,7 @@ HELP: command-name
     { $example
         "USING: io ui.commands ;"
         "IN: scratchpad"
-        ": com-my-command ;"
+        ": com-my-command ( -- ) ;"
         "\\ com-my-command command-name write"
         "My Command"
     }
index 101557d0cf80b353186a370e6f42c834a8c5344f..f79dcb54815da0c91a1d0cdb0b263efb3970878b 100644 (file)
@@ -307,7 +307,7 @@ HELP: find-last-integer
 { $notes "This word is used to implement " { $link find-last } "." } ;
 
 HELP: byte-array>bignum
-{ $values { "byte-array" byte-array } { "n" integer } }
+{ $values { "x" byte-array } { "y" bignum } }
 { $description "Converts a byte-array, interpreted as little-endian, into a bignum integer. User code should call " { $link le> } " or " { $link be> } " instead." } ;
 
 ARTICLE: "division-by-zero" "Division by zero"
index 11a6a9d8a991a1247219bf8ebb20b64a9739c9c0..995c7e6064677498d9a7fee3ed1c8b6c274508ba 100644 (file)
@@ -15,9 +15,9 @@ IN: memory.tests
 [ [ ] instances ] must-infer
 
 ! Code GC wasn't kicking in when needed
-: leak-step 800000 f <array> 1quotation call drop ;
+: leak-step ( -- ) 800000 f <array> 1quotation call drop ;
 
-: leak-loop 100 [ leak-step ] times ;
+: leak-loop ( -- ) 100 [ leak-step ] times ;
 
 [ ] [ leak-loop ] unit-test
 
index c5ca2b129f7f1befe266373d39b2af35fd9cc3a9..2aa8ef421c0175656a5e708b05e20da5b16700f7 100644 (file)
@@ -26,17 +26,17 @@ ABOUT: "strings"
 HELP: string
 { $description "The class of fixed-length character strings. See " { $link "syntax-strings" } " for syntax and " { $link "strings" } " for general information." } ;
 
-HELP: string-nth ( n string -- ch )
+HELP: string-nth
 { $values { "n" fixnum } { "string" string } { "ch" "the character at the " { $snippet "n" } "th index" } }
 { $description "Unsafe string accessor, used to define " { $link nth } " on strings." }
 { $warning "This word is in the " { $vocab-link "strings.private" } " vocabulary because it does not perform type or bounds checking. User code should call " { $link nth } " instead." } ;
 
-HELP: set-string-nth ( ch n string -- )
+HELP: set-string-nth
 { $values { "ch" "a character" } { "n" fixnum } { "string" string }  }
 { $description "Unsafe string mutator, used to define " { $link set-nth } " on strings." }
 { $warning "This word is in the " { $vocab-link "strings.private" } " vocabulary because it does not perform type or bounds checking. User code should call " { $link set-nth } " instead." } ;
 
-HELP: <string> ( n ch -- string )
+HELP: <string>
 { $values { "n" "a positive integer specifying string length" } { "ch" "an initial character" } { "string" string } }
 { $description "Creates a new string with the given length and all characters initially set to " { $snippet "ch" } "." } ;
 
index 7e4c80d4aeb2198681819be450310fbc6609313e..ffcefab78be4604309064e86112f9f9848b6f51f 100644 (file)
@@ -17,7 +17,7 @@ IN: strings
 : rehash-string ( str -- )
     1 over sequence-hashcode swap set-string-hashcode ; inline
 
-: set-string-nth ( ch n str -- )
+: set-string-nth ( ch n string -- )
     pick HEX: 7f fixnum<=
     [ set-string-nth-fast ] [ set-string-nth-slow ] if ; inline
 
index 79aeee5b554ef8b904ccd56d54889bb82ec2a659..6a7e8116cdd2409718f630f62c8243b2bfcb8d34 100644 (file)
@@ -180,7 +180,7 @@ HELP: delimiter
 HELP: SYNTAX:
 { $syntax "SYNTAX: foo ... ;" }
 { $description "Defines a parsing word." }
-{ $examples "In the below example, the " { $snippet "world" } " word is never called, however its body references a parsing word which executes immediately:" { $example "USE: io" "IN: scratchpad" "<< SYNTAX: HELLO \"Hello parser!\" print ; >>\n: world HELLO ;" "Hello parser!" } } ;
+{ $examples "In the below example, the " { $snippet "world" } " word is never called, however its body references a parsing word which executes immediately:" { $example "USE: io" "IN: scratchpad" "<< SYNTAX: HELLO \"Hello parser!\" print ; >>\n: world ( -- ) HELLO ;" "Hello parser!" } } ;
 
 HELP: inline
 { $syntax ": foo ... ; inline" }
index 63b58bf9d519201d07f6f506224f15c955592271..1ad6928acbab2e0c8319df57d765bd15328a0ee6 100644 (file)
@@ -165,7 +165,7 @@ HELP: execute ( word -- )
 { $values { "word" word } }
 { $description "Executes a word." }
 { $examples
-    { $example "USING: kernel io words ;" "IN: scratchpad" ": twice dup execute execute ;\n: hello \"Hello\" print ;\n\\ hello twice" "Hello\nHello" }
+    { $example "USING: kernel io words ;" "IN: scratchpad" ": twice ( word -- ) dup execute execute ;\n: hello ( -- ) \"Hello\" print ;\n\\ hello twice" "Hello\nHello" }
 } ;
 
 HELP: deferred
@@ -273,8 +273,8 @@ HELP: bootstrap-word
 { $values { "word" word } { "target" word } }
 { $description "Looks up a word with the same name and vocabulary as the given word, performing a transformation to handle parsing words in the target dictionary. Used during bootstrap to transfer host words to the target dictionary." } ;
 
-HELP: parsing-word? ( obj -- ? )
-{ $values { "obj" object } { "?" "a boolean" } }
+HELP: parsing-word?
+{ $values { "object" object } { "?" "a boolean" } }
 { $description "Tests if an object is a parsing word declared by " { $link POSTPONE: SYNTAX: } "." }
 { $notes "Outputs " { $link f } " if the object is not a word." } ;
 
index f22ca001f47e91a10ef7c8007d1f6a498d776cc3..19928b2e0bf22d568d83eb951aa7b4f28d8d34d1 100644 (file)
@@ -57,7 +57,7 @@ DEFER: check-status
         [ dup quit? [ quit-game ] [ repeat ] if ]
     if ;
 : build-quad ( -- array ) 4 [ 10 random ] replicate >array ;
-: 24-able? ( vector -- t/f ) [ makes-24? ] with-datastack first ;
+: 24-able? ( quad -- t/f ) [ makes-24? ] with-datastack first ;
 : 24-able ( -- vector ) build-quad dup 24-able? [ drop build-quad ] unless ;
 : set-commands ( -- ) { + - * / rot swap q } commands set ;
 : play-game ( -- ) set-commands 24-able repeat ;
index 000c0ce4cca8ca909357b8ba6331ba5f1f91287e..c875feab8348a71fcf210abfdbd00d681c0548db 100644 (file)
@@ -29,7 +29,7 @@ HELP: reset-progress ( -- )
     "a loop which makes use of " { $link progress } "."
 } ;
 
-HELP: progress ( -- time )
+HELP: progress
 { $values { "time" "an integer" } }
 { $description
     "Gives the time elapsed since the last time"
index 8ac4abe1fa0f2df62e695488947bb3aaf8f699eb..a5c7dbdde427ad043c0c2856cc70841fbbe4dd69 100644 (file)
@@ -9,7 +9,7 @@ SYMBOL: sleep-period
 
 : reset-progress ( -- ) millis last-loop set ;
 ! : my-progress ( -- progress ) millis 
-: progress ( -- progress ) millis last-loop get - reset-progress ;
+: progress ( -- time ) millis last-loop get - reset-progress ;
 : progress-peek ( -- progress ) millis last-loop get - ;
 : set-end ( duration -- end-time ) duration>milliseconds millis + ;
 : loop ( quot end -- ) dup millis > [ [ dup call ] dip loop ] [ 2drop ] if ; inline
index b984cdce543bfc84c82e138d0ce33bb1085a69ef..0377808dca795a26551c20d88746446b2a85e952 100644 (file)
@@ -36,7 +36,7 @@ HELP: ctags-write ( seq path -- )
 { $notes
   { $snippet "tags" } " file will contain a single line: if\\t/path/to/factor/extra/unix/unix.factor\\t91" } ;
 
-HELP: ctag-strings ( alist -- seq )
+HELP: ctag-strings
 { $values { "alist" "an association list" }
           { "seq" sequence } }
 { $description "Converts an " { $snippet "alist" } " with ctag format (a word as key and a sequence whose first element is a resource name and a second element is a line number as value) in a " { $snippet "seq" } " of ctag strings." }
index 393c9324825f7ee66c23110f52aee7ddca4a65fd..e351fbf7937457b1003ce677caccddd819a54553 100644 (file)
@@ -27,7 +27,7 @@ IN: ctags
     ctag-lineno number>string %
   ] "" make ;
 
-: ctag-strings ( seq1 -- seq2 )
+: ctag-strings ( alist -- seq )
   [ ctag ] map ;
 
 : ctags-write ( seq path -- )
index 6525264f6a59815975a432734e8ef468a9fa6535..0d61dcb467534b754c888e9131ed131fe90bba00 100644 (file)
@@ -21,7 +21,7 @@ CONSTANT: five 5
 USING: kernel literals prettyprint ;
 IN: scratchpad
 
-<< : seven-eleven 7 11 ; >>
+<< : seven-eleven ( -- a b ) 7 11 ; >>
 { $ seven-eleven } .
     "> "{ 7 11 }" }
 
@@ -37,7 +37,7 @@ HELP: $[
 USING: kernel literals math prettyprint ;
 IN: scratchpad
 
-<< : five 5 ; >>
+<< CONSTANT: five 5 >>
 { $[ five dup 1+ dup 2 + ] } .
     "> "{ 5 6 8 }" }
 
@@ -51,7 +51,7 @@ ARTICLE: "literals" "Interpolating code results into literal values"
 USING: kernel literals math prettyprint ;
 IN: scratchpad
 
-<< : five 5 ; >>
+<< CONSTANT: five 5 >>
 { $ five $[ five dup 1+ dup 2 + ] } .
     "> "{ 5 5 6 8 }" }
 { $subsection POSTPONE: $ }
index ec069a4894cb7b51b1d2a2366721e12ad7d93e1f..17f0de120e0db7c88f73d8a43aa4479e080f7030 100755 (executable)
@@ -1,11 +1,11 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel math sequences vectors classes classes.algebra
 combinators arrays words assocs parser namespaces make
 definitions prettyprint prettyprint.backend prettyprint.custom
 quotations generalizations debugger io compiler.units
 kernel.private effects accessors hashtables sorting shuffle
-math.order sets see ;
+math.order sets see effects.parser ;
 IN: multi-methods
 
 ! PART I: Converting hook specializers
@@ -214,17 +214,16 @@ M: no-method error.
     [ "multi-method-specializer" word-prop ]
     [ "multi-method-generic" word-prop ] bi prefix ;
 
-: define-generic ( word -- )
-    dup "multi-methods" word-prop [
-        drop
-    ] [
+: define-generic ( word effect -- )
+    over set-stack-effect
+    dup "multi-methods" word-prop [ drop ] [
         [ H{ } clone "multi-methods" set-word-prop ]
         [ update-generic ]
         bi
     ] if ;
 
 ! Syntax
-SYNTAX: GENERIC: CREATE define-generic ;
+SYNTAX: GENERIC: CREATE-WORD complete-effect define-generic ;
 
 : parse-method ( -- quot classes generic )
     parse-definition [ 2 tail ] [ second ] [ first ] tri ;
index 4169050e6fc171006c7e49b65023ec9a36515a5e..bf7955fa8456b59bbdeac7b866a37d591b999232 100644 (file)
@@ -140,11 +140,11 @@ METHOD: as-mutate { object object assoc }       set-at ;
 
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-: filter-of ( quot seq -- seq ) swap filter ;
+: filter-of ( quot seq -- seq ) swap filter ; inline
 
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-: map-over ( quot seq -- seq ) swap map ;
+: map-over ( quot seq -- seq ) swap map ; inline
 
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
@@ -242,7 +242,7 @@ METHOD: as-mutate { object object assoc }       set-at ;
 
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-: purge ( seq quot -- seq ) [ not ] compose filter ;
+: purge ( seq quot -- seq ) [ not ] compose filter ; inline
 
 : purge! ( seq quot -- seq )
-  dupd '[ swap @ [ pluck! ] [ drop ] if ] each-index ;
+  dupd '[ swap @ [ pluck! ] [ drop ] if ] each-index ; inline
diff --git a/extra/promises/authors.txt b/extra/promises/authors.txt
deleted file mode 100644 (file)
index 44b06f9..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Chris Double
diff --git a/extra/promises/promises-docs.factor b/extra/promises/promises-docs.factor
deleted file mode 100755 (executable)
index d416842..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-! Copyright (C) 2006 Chris Double.
-! See http://factorcode.org/license.txt for BSD license.
-USING: help.markup help.syntax ;
-IN: promises
-
-HELP: promise 
-{ $values { "quot" { $quotation "( -- X )" } } { "promise" "a promise object" } }
-{ $description "Creates a promise to return a value. When forced this quotation is called and the value returned. The value is memorised so that calling " { $link force } " again does not call the quotation again, instead the previous value is returned directly." } ;
-
-HELP: force
-{ $values { "promise" "a promise object" } { "value" "a factor object" } }
-{ $description "Calls the quotation associated with the promise if it has not been called before, and returns the value. If the promise has been forced previously, returns the value from the previous call." } ;
-
-HELP: LAZY:
-{ $syntax "LAZY: word ( stack -- effect ) definition... ;" } 
-{ $values { "word" "a new word to define" } { "definition" "a word definition" } }
-{ $description "Creates a lazy word in the current vocabulary. When executed the word will return a " { $link promise } " that when forced, executes the word definition. Any values on the stack that are required by the word definition are captured along with the promise." } 
-{ $examples
-  { $example "USING: arrays sequences prettyprint promises ;" "IN: scratchpad" "LAZY: zeroes ( -- pair ) 0 zeroes 2array ;" "zeroes force second force first ." "0" }
-} ;
diff --git a/extra/promises/promises-tests.factor b/extra/promises/promises-tests.factor
deleted file mode 100644 (file)
index 79e7dc5..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-IN: promises.tests
-USING: promises math tools.test ;
-
-LAZY: lazy-test ( a -- b ) 1 + ;
-
-{ 1 1 } [ lazy-test ] must-infer-as
-[ 3 ] [ 2 lazy-test force ] unit-test
\ No newline at end of file
diff --git a/extra/promises/promises.factor b/extra/promises/promises.factor
deleted file mode 100755 (executable)
index c3951f4..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-! Copyright (C) 2004, 2006 Chris Double, Matthew Willis.
-! See http://factorcode.org/license.txt for BSD license.
-USING: arrays kernel sequences math arrays namespaces
-parser effects generalizations fry words accessors ;
-IN: promises
-
-TUPLE: promise quot forced? value ;
-
-: promise ( quot -- promise ) f f \ promise boa ;
-
-: force ( promise -- value )
-    dup forced?>> [
-        dup quot>> call( -- value ) >>value
-        t >>forced?
-    ] unless
-    value>> ;
-
-: make-lazy-quot ( quot effect -- quot )
-    in>> length '[ _ _ ncurry promise ] ;
-
-SYNTAX: LAZY:
-    (:) [ make-lazy-quot ] [ 2nip ] 3bi define-declared ;
diff --git a/extra/promises/summary.txt b/extra/promises/summary.txt
deleted file mode 100644 (file)
index d64fe20..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Lazy thunks
diff --git a/extra/promises/tags.txt b/extra/promises/tags.txt
deleted file mode 100644 (file)
index f427429..0000000
+++ /dev/null
@@ -1 +0,0 @@
-extensions
index 6c56300f6df0fa71accbb07902b96c4e53240c9d..852fe59d8bd5925f2a02a3a1b3bf34580c800e4d 100644 (file)
@@ -10,7 +10,7 @@ HELP: <n-based-assoc>
 USING: assocs prettyprint kernel sequences.n-based ;
 IN: scratchpad
 
-: months
+: months ( -- assoc )
     {
         "January"
         "February"
@@ -36,7 +36,7 @@ HELP: n-based-assoc
 USING: assocs prettyprint kernel sequences.n-based ;
 IN: scratchpad
 
-: months
+: months ( -- assoc )
     {
         "January"
         "February"