From 0d346a02680b3c9da8658ee0125139830f413adc Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Fri, 4 May 2012 22:24:21 -0700 Subject: [PATCH] memoize: moving MEMO[ to memoize.syntax to work around bootstrap issue. --- basis/memoize/memoize-docs.factor | 4 ---- basis/memoize/memoize-tests.factor | 11 ++--------- basis/memoize/memoize.factor | 5 +---- basis/memoize/syntax/syntax-docs.factor | 6 ++++++ basis/memoize/syntax/syntax-tests.factor | 10 ++++++++++ basis/memoize/syntax/syntax.factor | 6 ++++++ 6 files changed, 25 insertions(+), 17 deletions(-) create mode 100644 basis/memoize/syntax/syntax-docs.factor create mode 100644 basis/memoize/syntax/syntax-tests.factor create mode 100644 basis/memoize/syntax/syntax.factor diff --git a/basis/memoize/memoize-docs.factor b/basis/memoize/memoize-docs.factor index 5365665f1f..426bd2916c 100644 --- a/basis/memoize/memoize-docs.factor +++ b/basis/memoize/memoize-docs.factor @@ -26,8 +26,4 @@ HELP: MEMO: { $values { "word" "a new word to define" } { "definition" "a word definition" } } { $description "Defines the given word at parse time as one which memoizes its output given a particular input. The stack effect is mandatory." } ; -HELP: MEMO[ -{ $syntax "MEMO[ elements... ]" } -{ $description "Defines the given literal quotation as one which memoizes its outputs given a particular input." } ; - { define-memoized POSTPONE: MEMO: } related-words diff --git a/basis/memoize/memoize-tests.factor b/basis/memoize/memoize-tests.factor index 2ad14e8cec..e89685263d 100644 --- a/basis/memoize/memoize-tests.factor +++ b/basis/memoize/memoize-tests.factor @@ -1,8 +1,7 @@ ! Copyright (C) 2007, 2009 Slava Pestov, Daniel Ehrenberg. ! See http://factorcode.org/license.txt for BSD license. -USING: calendar math math.order kernel memoize tools.test parser -generalizations prettyprint io.streams.string sequences eval -namespaces see threads tools.time ; +USING: math kernel memoize tools.test parser generalizations +prettyprint io.streams.string sequences eval namespaces see ; IN: memoize.tests MEMO: fib ( m -- n ) @@ -34,9 +33,3 @@ unit-test [ sq ] ( a -- b ) memoize-quot "q" set [ 9 ] [ 3 "q" get call ] unit-test - -[ t ] [ - { 1/8 1/8 1/8 1/8 1/16 1/16 1/16 } - [ MEMO[ seconds sleep ] each ] benchmark - 0.18e9 0.25e9 between? -] unit-test diff --git a/basis/memoize/memoize.factor b/basis/memoize/memoize.factor index a595d5d3d9..1817cf83a9 100644 --- a/basis/memoize/memoize.factor +++ b/basis/memoize/memoize.factor @@ -2,8 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: kernel hashtables sequences sequences.private arrays words namespaces make parser effects.parser math assocs effects -definitions quotations summary accessors fry hashtables.identity -stack-checker ; +definitions quotations summary accessors fry hashtables.identity ; IN: memoize > packer call ] [ "memoize" word-prop delete-at ] bi ; \ invalidate-memoized t "no-compile" set-word-prop - -SYNTAX: MEMO[ parse-quotation dup infer memoize-quot suffix! ; diff --git a/basis/memoize/syntax/syntax-docs.factor b/basis/memoize/syntax/syntax-docs.factor new file mode 100644 index 0000000000..d4eba04bb0 --- /dev/null +++ b/basis/memoize/syntax/syntax-docs.factor @@ -0,0 +1,6 @@ + +USING: help.markup help.syntax memoize.syntax ; + +HELP: MEMO[ +{ $syntax "MEMO[ elements... ]" } +{ $description "Defines the given literal quotation as one which memoizes its outputs given a particular input." } ; diff --git a/basis/memoize/syntax/syntax-tests.factor b/basis/memoize/syntax/syntax-tests.factor new file mode 100644 index 0000000000..4592c92fe7 --- /dev/null +++ b/basis/memoize/syntax/syntax-tests.factor @@ -0,0 +1,10 @@ +USING: calendar math.order memoize.syntax sequences threads +tools.test tools.time ; + +IN: memoize.syntax.tests + +[ t ] [ + { 1/8 1/8 1/8 1/8 1/16 1/16 1/16 } + [ MEMO[ seconds sleep ] each ] benchmark + 0.18e9 0.25e9 between? +] unit-test diff --git a/basis/memoize/syntax/syntax.factor b/basis/memoize/syntax/syntax.factor new file mode 100644 index 0000000000..943f2c4f63 --- /dev/null +++ b/basis/memoize/syntax/syntax.factor @@ -0,0 +1,6 @@ +USING: kernel memoize parser sequences stack-checker ; + +IN: memoize.syntax + +SYNTAX: MEMO[ parse-quotation dup infer memoize-quot suffix! ; +