From 87121c1468063196b3a210369ecc1fe1f8798dc6 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 5 Apr 2009 20:44:12 -0500 Subject: [PATCH 01/20] Fix prettyprinting of URLs --- basis/urls/prettyprint/prettyprint.factor | 7 +++++-- basis/urls/urls-tests.factor | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/basis/urls/prettyprint/prettyprint.factor b/basis/urls/prettyprint/prettyprint.factor index 59fb79e8d3..35e428c8fa 100644 --- a/basis/urls/prettyprint/prettyprint.factor +++ b/basis/urls/prettyprint/prettyprint.factor @@ -1,6 +1,9 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel present prettyprint.custom prettyprint.backend urls ; +USING: kernel present prettyprint.custom prettyprint.sections +prettyprint.backend urls ; IN: urls.prettyprint -M: url pprint* dup present "URL\" " "\"" pprint-string ; +M: url pprint* + \ URL" record-vocab + dup present "URL\" " "\"" pprint-string ; diff --git a/basis/urls/urls-tests.factor b/basis/urls/urls-tests.factor index 74eea9506c..f45ad6449e 100644 --- a/basis/urls/urls-tests.factor +++ b/basis/urls/urls-tests.factor @@ -1,5 +1,5 @@ IN: urls.tests -USING: urls urls.private tools.test +USING: urls urls.private tools.test prettyprint arrays kernel assocs present accessors ; CONSTANT: urls @@ -227,3 +227,5 @@ urls [ [ "http://localhost/?foo=bar" >url ] unit-test [ "/" ] [ "http://www.jedit.org" >url path>> ] unit-test + +[ "USING: urls ;\nURL\" foo\"" ] [ URL" foo" unparse-use ] unit-test \ No newline at end of file From 68728d1cc4d82d688ff7c46990efd96b27b90c84 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 5 Apr 2009 20:44:34 -0500 Subject: [PATCH 02/20] Fix prettyprint of CONSTANT: and ALIAS: --- basis/see/see-tests.factor | 11 +++++++++++ basis/see/see.factor | 12 ++++++++++-- core/words/alias/alias.factor | 7 ++++--- core/words/constant/constant-tests.factor | 14 ++++++++++++++ core/words/constant/constant.factor | 8 ++++++-- 5 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 basis/see/see-tests.factor create mode 100644 core/words/constant/constant-tests.factor diff --git a/basis/see/see-tests.factor b/basis/see/see-tests.factor new file mode 100644 index 0000000000..3f11ec987e --- /dev/null +++ b/basis/see/see-tests.factor @@ -0,0 +1,11 @@ +IN: see.tests +USING: see tools.test io.streams.string math ; + +CONSTANT: test-const 10 +[ "IN: see.tests\nCONSTANT: test-const 10 inline\n" ] +[ [ \ test-const see ] with-string-writer ] unit-test + +ALIAS: test-alias + + +[ "USING: math ;\nIN: see.tests\nALIAS: test-alias + inline\n" ] +[ [ \ test-alias see ] with-string-writer ] unit-test diff --git a/basis/see/see.factor b/basis/see/see.factor index 32f49499db..9fc14ff581 100644 --- a/basis/see/see.factor +++ b/basis/see/see.factor @@ -7,7 +7,7 @@ definitions effects generic generic.standard io io.pathnames io.streams.string io.styles kernel make namespaces prettyprint prettyprint.backend prettyprint.config prettyprint.custom prettyprint.sections sequences sets sorting strings summary -words words.symbol ; +words words.symbol words.constant words.alias ; IN: see GENERIC: synopsis* ( defspec -- ) @@ -29,8 +29,16 @@ GENERIC: see* ( defspec -- ) : comment. ( text -- ) H{ { font-style italic } } styled-text ; +GENERIC: print-stack-effect? ( word -- ? ) + +M: parsing-word print-stack-effect? drop f ; +M: symbol print-stack-effect? drop f ; +M: constant print-stack-effect? drop f ; +M: alias print-stack-effect? drop f ; +M: word print-stack-effect? drop t ; + : stack-effect. ( word -- ) - [ [ parsing-word? ] [ symbol? ] bi or not ] [ stack-effect ] bi and + [ print-stack-effect? ] [ stack-effect ] bi and [ effect>string comment. ] when* ; > first stack-effect ; +M: alias definer drop \ ALIAS: f ; + +M: alias definition def>> first 1quotation ; \ No newline at end of file diff --git a/core/words/constant/constant-tests.factor b/core/words/constant/constant-tests.factor new file mode 100644 index 0000000000..2755039af6 --- /dev/null +++ b/core/words/constant/constant-tests.factor @@ -0,0 +1,14 @@ +IN: words.constant.tests +USING: tools.test math ; + +CONSTANT: a + + +[ + ] [ a ] unit-test + +CONSTANT: b \ + + +[ \ + ] [ b ] unit-test + +CONSTANT: c { 1 2 3 } + +[ { 1 2 3 } ] [ c ] unit-test diff --git a/core/words/constant/constant.factor b/core/words/constant/constant.factor index 43b7f37599..00302df98a 100644 --- a/core/words/constant/constant.factor +++ b/core/words/constant/constant.factor @@ -1,6 +1,6 @@ -! Copyright (C) 2008 Slava Pestov. +! Copyright (C) 2008, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors kernel sequences words ; +USING: accessors kernel sequences words definitions quotations ; IN: words.constant PREDICATE: constant < word ( obj -- ? ) @@ -8,3 +8,7 @@ PREDICATE: constant < word ( obj -- ? ) : define-constant ( word value -- ) [ ] curry (( -- value )) define-inline ; + +M: constant definer drop \ CONSTANT: f ; + +M: constant definition def>> first literalize 1quotation ; \ No newline at end of file From 880f4097adf08767d96f014cd2476fa835e54b38 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 5 Apr 2009 20:50:45 -0500 Subject: [PATCH 03/20] Clear button in search field is now positioned correctly --- basis/ui/gadgets/search-tables/search-tables-tests.factor | 3 +++ basis/ui/gadgets/search-tables/search-tables.factor | 1 + 2 files changed, 4 insertions(+) create mode 100644 basis/ui/gadgets/search-tables/search-tables-tests.factor diff --git a/basis/ui/gadgets/search-tables/search-tables-tests.factor b/basis/ui/gadgets/search-tables/search-tables-tests.factor new file mode 100644 index 0000000000..5a627286f9 --- /dev/null +++ b/basis/ui/gadgets/search-tables/search-tables-tests.factor @@ -0,0 +1,3 @@ +IN: ui.gadgets.search-tables.tests +USING: ui.gadgets.search-tables sequences tools.test ; +[ [ second ] ] must-infer diff --git a/basis/ui/gadgets/search-tables/search-tables.factor b/basis/ui/gadgets/search-tables/search-tables.factor index 4a2983bfe0..17570a8714 100644 --- a/basis/ui/gadgets/search-tables/search-tables.factor +++ b/basis/ui/gadgets/search-tables/search-tables.factor @@ -28,6 +28,7 @@ TUPLE: search-field < track field ; : ( model -- gadget ) horizontal search-field new-track + 0 >>fill { 5 5 } >>gap +baseline+ >>align swap 10 >>min-cols >>field From 687e9f90fe70c5e0491995fa911d797b9eaf07d3 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 5 Apr 2009 23:16:48 -0500 Subject: [PATCH 04/20] Move models.history to extra --- basis/models/models-docs.factor | 1 - {basis => extra}/models/history/history-docs.factor | 0 {basis => extra}/models/history/history-tests.factor | 0 {basis => extra}/models/history/history.factor | 0 {basis => extra}/models/history/summary.txt | 0 5 files changed, 1 deletion(-) rename {basis => extra}/models/history/history-docs.factor (100%) rename {basis => extra}/models/history/history-tests.factor (100%) rename {basis => extra}/models/history/history.factor (100%) rename {basis => extra}/models/history/summary.txt (100%) diff --git a/basis/models/models-docs.factor b/basis/models/models-docs.factor index 2b90bdb0d5..8f40a8adbe 100644 --- a/basis/models/models-docs.factor +++ b/basis/models/models-docs.factor @@ -133,7 +133,6 @@ $nl { $subsection "models-impl" } { $subsection "models.arrow" } { $subsection "models.product" } -{ $subsection "models-history" } { $subsection "models-range" } { $subsection "models-delay" } ; diff --git a/basis/models/history/history-docs.factor b/extra/models/history/history-docs.factor similarity index 100% rename from basis/models/history/history-docs.factor rename to extra/models/history/history-docs.factor diff --git a/basis/models/history/history-tests.factor b/extra/models/history/history-tests.factor similarity index 100% rename from basis/models/history/history-tests.factor rename to extra/models/history/history-tests.factor diff --git a/basis/models/history/history.factor b/extra/models/history/history.factor similarity index 100% rename from basis/models/history/history.factor rename to extra/models/history/history.factor diff --git a/basis/models/history/summary.txt b/extra/models/history/summary.txt similarity index 100% rename from basis/models/history/summary.txt rename to extra/models/history/summary.txt From 8bf5fde791b992a73761614e6024982a804317df Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 5 Apr 2009 23:18:25 -0500 Subject: [PATCH 05/20] Rename scroll word to set-scroll-position and make it public --- .../gadgets/scrollers/scrollers-docs.factor | 8 +++--- .../gadgets/scrollers/scrollers-tests.factor | 2 +- basis/ui/gadgets/scrollers/scrollers.factor | 25 ++++++++++--------- basis/ui/gadgets/viewports/viewports.factor | 4 +-- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/basis/ui/gadgets/scrollers/scrollers-docs.factor b/basis/ui/gadgets/scrollers/scrollers-docs.factor index 8e0131ec31..92831bea00 100644 --- a/basis/ui/gadgets/scrollers/scrollers-docs.factor +++ b/basis/ui/gadgets/scrollers/scrollers-docs.factor @@ -11,11 +11,11 @@ HELP: find-scroller { $values { "gadget" gadget } { "scroller/f" { $maybe scroller } } } { $description "Finds the first parent of " { $snippet "gadget" } " which is a " { $link scroller } ". Outputs " { $link f } " if the gadget is not contained in a " { $link scroller } "." } ; -HELP: scroller-value +HELP: scroll-position { $values { "scroller" scroller } { "loc" "a pair of integers" } } { $description "Outputs the offset of the top-left corner of the scroller's " { $link viewport } "'s child." } ; -{ scroller-value scroll scroll>bottom scroll>top scroll>rect } related-words +{ scroll-position scroll scroll>bottom scroll>top scroll>rect } related-words HELP: { $values { "gadget" gadget } { "scroller" "a new " { $link scroller } } } @@ -48,8 +48,8 @@ ARTICLE: "ui.gadgets.scrollers" "Scroller gadgets" { $subsection scroller } { $subsection } "Getting and setting the scroll position:" -{ $subsection scroller-value } -{ $subsection scroll } +{ $subsection scroll-position } +{ $subsection set-scroll-position } "Writing scrolling-aware gadgets:" { $subsection scroll>bottom } { $subsection scroll>top } diff --git a/basis/ui/gadgets/scrollers/scrollers-tests.factor b/basis/ui/gadgets/scrollers/scrollers-tests.factor index d4cdc95daf..cf63d616be 100644 --- a/basis/ui/gadgets/scrollers/scrollers-tests.factor +++ b/basis/ui/gadgets/scrollers/scrollers-tests.factor @@ -74,7 +74,7 @@ dup layout drop "g2" get scroll>gadget "s" get layout - "s" get scroller-value + "s" get scroll-position ] map [ { 0 0 } = ] all? ] unit-test diff --git a/basis/ui/gadgets/scrollers/scrollers.factor b/basis/ui/gadgets/scrollers/scrollers.factor index a526cc618b..0852a6fe5d 100644 --- a/basis/ui/gadgets/scrollers/scrollers.factor +++ b/basis/ui/gadgets/scrollers/scrollers.factor @@ -29,6 +29,13 @@ M: gadget viewport-column-header drop f ; : scroll-down-line ( scroller -- ) y>> 1 swap slide-by-line ; +: set-scroll-position ( value scroller -- ) + [ + viewport>> [ dim>> { 0 0 } ] [ gadget-child pref-dim ] bi + 4array flip + ] keep + 2dup control-value = [ 2drop ] [ set-control-value ] if ; + > [ dim>> { 0 0 } ] [ gadget-child pref-dim ] bi - 4array flip - ] keep - 2dup control-value = [ 2drop ] [ set-control-value ] if ; - : (scroll>rect) ( rect scroller -- ) { - [ scroller-value vneg offset-rect ] + [ scroll-position vneg offset-rect ] [ viewport>> dim>> rect-min ] [ viewport>> loc>> offset-rect ] [ viewport>> [ v- { 0 0 } vmin ] [ v- { 0 0 } vmax ] with-rect-extents v+ ] - [ scroller-value v+ ] - [ scroll ] + [ scroll-position v+ ] + [ set-scroll-position ] } cleave ; : relative-scroll-rect ( rect gadget scroller -- newrect ) @@ -72,7 +72,7 @@ M: viewport pref-dim* gadget-child pref-viewport-dim ; 2&& ; : (update-scroller) ( scroller -- ) - [ scroller-value ] keep scroll ; + [ scroll-position ] keep set-scroll-position ; : (scroll>gadget) ( gadget scroller -- ) 2dup swap child? [ @@ -82,7 +82,8 @@ M: viewport pref-dim* gadget-child pref-viewport-dim ; ] [ f >>follows (update-scroller) drop ] if ; : (scroll>bottom) ( scroller -- ) - [ viewport>> gadget-child pref-dim { 0 1 } v* ] keep scroll ; + [ viewport>> gadget-child pref-dim { 0 1 } v* ] keep + set-scroll-position ; GENERIC: update-scroller ( scroller follows -- ) diff --git a/basis/ui/gadgets/viewports/viewports.factor b/basis/ui/gadgets/viewports/viewports.factor index c14c7f01fb..b154ef2322 100644 --- a/basis/ui/gadgets/viewports/viewports.factor +++ b/basis/ui/gadgets/viewports/viewports.factor @@ -23,7 +23,7 @@ M: viewport layout* M: viewport focusable-child* gadget-child ; -: scroller-value ( scroller -- loc ) +: scroll-position ( scroller -- loc ) model>> range-value [ >integer ] map ; M: viewport model-changed @@ -31,7 +31,7 @@ M: viewport model-changed [ relayout-1 ] [ [ gadget-child ] - [ scroller-value vneg ] + [ scroll-position vneg ] [ constraint>> ] tri v* >>loc drop ] bi ; From 78013c2bdffc9f579bbe1d8c137c265f32b7e77e Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 5 Apr 2009 23:19:18 -0500 Subject: [PATCH 06/20] Rename scroll word to set-scroll-position and make it public --- basis/ui/gadgets/scrollers/scrollers-docs.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/ui/gadgets/scrollers/scrollers-docs.factor b/basis/ui/gadgets/scrollers/scrollers-docs.factor index 92831bea00..011afa5c97 100644 --- a/basis/ui/gadgets/scrollers/scrollers-docs.factor +++ b/basis/ui/gadgets/scrollers/scrollers-docs.factor @@ -15,7 +15,7 @@ HELP: scroll-position { $values { "scroller" scroller } { "loc" "a pair of integers" } } { $description "Outputs the offset of the top-left corner of the scroller's " { $link viewport } "'s child." } ; -{ scroll-position scroll scroll>bottom scroll>top scroll>rect } related-words +{ scroll-position set-scroll-position scroll>bottom scroll>top scroll>rect } related-words HELP: { $values { "gadget" gadget } { "scroller" "a new " { $link scroller } } } @@ -23,7 +23,7 @@ HELP: { } related-words -HELP: scroll +HELP: set-scroll-position { $values { "scroller" scroller } { "value" "a pair of integers" } } { $description "Sets the offset of the top-left corner of the scroller's " { $link viewport } "'s child." } ; From 88bbb47bfa31afb37513628286b4146198da93f0 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 5 Apr 2009 23:19:35 -0500 Subject: [PATCH 07/20] Browser tool now saves scroll bar position in history --- basis/ui/tools/browser/browser.factor | 41 ++++++++++++------- basis/ui/tools/browser/history/authors.txt | 1 + .../browser/history/history-tests.factor | 36 ++++++++++++++++ basis/ui/tools/browser/history/history.factor | 32 +++++++++++++++ 4 files changed, 95 insertions(+), 15 deletions(-) create mode 100644 basis/ui/tools/browser/history/authors.txt create mode 100644 basis/ui/tools/browser/history/history-tests.factor create mode 100644 basis/ui/tools/browser/history/history.factor diff --git a/basis/ui/tools/browser/browser.factor b/basis/ui/tools/browser/browser.factor index e242b743f8..0c6e1fe05a 100644 --- a/basis/ui/tools/browser/browser.factor +++ b/basis/ui/tools/browser/browser.factor @@ -1,23 +1,33 @@ ! Copyright (C) 2006, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: debugger help help.topics help.crossref help.home kernel -models compiler.units assocs words vocabs accessors fry -combinators.short-circuit namespaces sequences models -models.history help.apropos combinators ui.commands ui.gadgets -ui.gadgets.panes ui.gadgets.scrollers ui.gadgets.tracks -ui.gestures ui.gadgets.buttons ui.gadgets.packs -ui.gadgets.editors ui.gadgets.labels ui.gadgets.status-bar -ui.gadgets.glass ui.gadgets.borders ui.tools.common -ui.tools.browser.popups ui ; +USING: debugger help help.topics help.crossref help.home kernel models +compiler.units assocs words vocabs accessors fry arrays +combinators.short-circuit namespaces sequences models help.apropos +combinators ui ui.commands ui.gadgets ui.gadgets.panes +ui.gadgets.scrollers ui.gadgets.tracks ui.gestures ui.gadgets.buttons +ui.gadgets.packs ui.gadgets.editors ui.gadgets.labels +ui.gadgets.status-bar ui.gadgets.glass ui.gadgets.borders ui.gadgets.viewports +ui.tools.common ui.tools.browser.popups ui.tools.browser.history ; IN: ui.tools.browser -TUPLE: browser-gadget < tool pane scroller search-field popup ; +TUPLE: browser-gadget < tool history pane scroller search-field popup ; { 650 400 } browser-gadget set-tool-dim +M: browser-gadget history-value + [ control-value ] [ scroller>> scroll-position ] + bi 2array ; + +M: browser-gadget set-history-value + [ first2 ] dip + [ set-control-value ] [ scroller>> set-scroll-position ] + bi-curry bi* ; + : show-help ( link browser-gadget -- ) - [ >link ] [ model>> ] bi* - [ [ add-recent ] [ add-history ] bi* ] [ set-model ] 2bi ; + [ >link ] dip + [ [ add-recent ] [ history>> add-history ] bi* ] + [ model>> set-model ] + 2bi ; : ( browser-gadget -- gadget ) model>> [ '[ _ print-topic ] try ] ; @@ -41,7 +51,8 @@ TUPLE: browser-gadget < tool pane scroller search-field popup ; : ( link -- gadget ) vertical browser-gadget new-track 1 >>fill - swap >link >>model + swap >link >>model + dup >>history dup >>search-field dup { 3 3 } { 1 0 } >>fill f track-add dup >>pane @@ -93,9 +104,9 @@ M: browser-gadget focusable-child* search-field>> ; \ show-browser H{ { +nullary+ t } } define-command -: com-back ( browser -- ) model>> go-back ; +: com-back ( browser -- ) history>> go-back ; -: com-forward ( browser -- ) model>> go-forward ; +: com-forward ( browser -- ) history>> go-forward ; : com-home ( browser -- ) "help.home" swap show-help ; diff --git a/basis/ui/tools/browser/history/authors.txt b/basis/ui/tools/browser/history/authors.txt new file mode 100644 index 0000000000..d4f5d6b3ae --- /dev/null +++ b/basis/ui/tools/browser/history/authors.txt @@ -0,0 +1 @@ +Slava Pestov \ No newline at end of file diff --git a/basis/ui/tools/browser/history/history-tests.factor b/basis/ui/tools/browser/history/history-tests.factor new file mode 100644 index 0000000000..20b16f450a --- /dev/null +++ b/basis/ui/tools/browser/history/history-tests.factor @@ -0,0 +1,36 @@ +USING: namespaces ui.tools.browser.history sequences tools.test ; +IN: ui.tools.browser.history.tests + +f "history" set + +"history" get add-history + +[ t ] [ "history" get back>> empty? ] unit-test +[ t ] [ "history" get forward>> empty? ] unit-test + +"history" get add-history +"history" get 3 >>value drop + +[ t ] [ "history" get back>> empty? ] unit-test +[ t ] [ "history" get forward>> empty? ] unit-test + +"history" get add-history +"history" get 4 >>value drop + +[ f ] [ "history" get back>> empty? ] unit-test +[ t ] [ "history" get forward>> empty? ] unit-test + +"history" get go-back + +[ 3 ] [ "history" get value>> ] unit-test + +[ t ] [ "history" get back>> empty? ] unit-test +[ f ] [ "history" get forward>> empty? ] unit-test + +"history" get go-forward + +[ 4 ] [ "history" get value>> ] unit-test + +[ f ] [ "history" get back>> empty? ] unit-test +[ t ] [ "history" get forward>> empty? ] unit-test + diff --git a/basis/ui/tools/browser/history/history.factor b/basis/ui/tools/browser/history/history.factor new file mode 100644 index 0000000000..f80189c783 --- /dev/null +++ b/basis/ui/tools/browser/history/history.factor @@ -0,0 +1,32 @@ +! Copyright (C) 2009 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: kernel accessors sequences locals ; +IN: ui.tools.browser.history + +TUPLE: history owner back forward ; + +: ( owner -- history ) + V{ } clone V{ } clone history boa ; + +GENERIC: history-value ( object -- value ) + +GENERIC: set-history-value ( value object -- ) + +: (add-history) ( history to -- ) + swap owner>> history-value dup [ swap push ] [ 2drop ] if ; + +:: go-back/forward ( history to from -- ) + from empty? [ + history to (add-history) + from pop history owner>> set-history-value + ] unless ; + +: go-back ( history -- ) + dup [ forward>> ] [ back>> ] bi go-back/forward ; + +: go-forward ( history -- ) + dup [ back>> ] [ forward>> ] bi go-back/forward ; + +: add-history ( history -- ) + dup forward>> delete-all + dup back>> (add-history) ; \ No newline at end of file From cb6030778f78d75ec1bcb2a28873cd9ab05bbc2f Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 5 Apr 2009 23:38:47 -0500 Subject: [PATCH 08/20] Fix ui.gadgets.scrollers unit tests --- basis/ui/gadgets/scrollers/scrollers-tests.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/ui/gadgets/scrollers/scrollers-tests.factor b/basis/ui/gadgets/scrollers/scrollers-tests.factor index cf63d616be..22df1f328b 100644 --- a/basis/ui/gadgets/scrollers/scrollers-tests.factor +++ b/basis/ui/gadgets/scrollers/scrollers-tests.factor @@ -45,13 +45,13 @@ IN: ui.gadgets.scrollers.tests [ { 100 100 } ] [ "s" get viewport>> gadget-child pref-dim ] unit-test - [ ] [ { 0 0 } "s" get scroll ] unit-test + [ ] [ { 0 0 } "s" get set-scroll-position ] unit-test [ { 0 0 } ] [ "s" get model>> range-min-value ] unit-test [ { 100 100 } ] [ "s" get model>> range-max-value ] unit-test - [ ] [ { 10 20 } "s" get scroll ] unit-test + [ ] [ { 10 20 } "s" get set-scroll-position ] unit-test [ { 10 20 } ] [ "s" get model>> range-value ] unit-test From 42f3b0e16e8d327c048053663788fe096986ca89 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 6 Apr 2009 01:10:34 -0500 Subject: [PATCH 09/20] Fix bootstrap errors --- basis/bootstrap/stage2.factor | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/basis/bootstrap/stage2.factor b/basis/bootstrap/stage2.factor index 6c824b6155..12741f2170 100644 --- a/basis/bootstrap/stage2.factor +++ b/basis/bootstrap/stage2.factor @@ -45,11 +45,18 @@ SYMBOL: bootstrap-time [ optimized>> ] count-words " compiled words" print [ symbol? ] count-words " symbol words" print [ ] count-words " words total" print - + "Bootstrapping is complete." print "Now, you can run Factor:" print vm write " -i=" write "output-image" get print flush ; +: save/restore-error ( quot -- ) + error get-global + error-continuation get-global + [ call ] 2dip + error-continuation set-global + error set-global ; inline + [ ! We time bootstrap millis @@ -104,6 +111,7 @@ SYMBOL: bootstrap-time drop [ load-help? off - "vocab:bootstrap/bootstrap-error.factor" run-file + [ "vocab:bootstrap/bootstrap-error.factor" parse-file ] save/restore-error + call ] with-scope ] recover From 3752c706da151d168dbddf903c6ca4a91e41b5a9 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 6 Apr 2009 02:57:39 -0500 Subject: [PATCH 10/20] Add M\ syntax for method literals --- basis/prettyprint/backend/backend.factor | 32 +++++++++++----------- basis/prettyprint/prettyprint-tests.factor | 22 --------------- core/bootstrap/syntax.factor | 1 + core/syntax/syntax-docs.factor | 4 +++ core/syntax/syntax.factor | 1 + 5 files changed, 22 insertions(+), 38 deletions(-) diff --git a/basis/prettyprint/backend/backend.factor b/basis/prettyprint/backend/backend.factor index bcd91a4d94..8004c1141f 100644 --- a/basis/prettyprint/backend/backend.factor +++ b/basis/prettyprint/backend/backend.factor @@ -41,18 +41,18 @@ M: effect pprint* effect>string "(" ")" surround text ; : pprint-prefix ( word quot -- ) ; inline +M: parsing-word pprint* + \ POSTPONE: [ pprint-word ] pprint-prefix ; + M: word pprint* - dup parsing-word? [ - \ POSTPONE: [ pprint-word ] pprint-prefix - ] [ - { - [ "break-before" word-prop line-break ] - [ pprint-word ] - [ ?start-group ] - [ ?end-group ] - [ "break-after" word-prop line-break ] - } cleave - ] if ; + [ pprint-word ] [ ?start-group ] [ ?end-group ] tri ; + +M: method-body pprint* + ; M: real pprint* number>string text ; @@ -206,8 +206,8 @@ M: curry pprint* pprint-object ; M: compose pprint* pprint-object ; M: wrapper pprint* - dup wrapped>> word? [ - > pprint-word block> - ] [ - pprint-object - ] if ; + { + { [ dup wrapped>> method-body? ] [ wrapped>> pprint* ] } + { [ dup wrapped>> word? ] [ > pprint-word block> ] } + [ pprint-object ] + } cond ; diff --git a/basis/prettyprint/prettyprint-tests.factor b/basis/prettyprint/prettyprint-tests.factor index 7e37aa0da5..3350ae6c7b 100644 --- a/basis/prettyprint/prettyprint-tests.factor +++ b/basis/prettyprint/prettyprint-tests.factor @@ -180,28 +180,6 @@ DEFER: parse-error-file "string-layout-test" string-layout check-see ] unit-test -! Define dummy words for the below... -: ( a b c d -- e ) ; -: ( -- fmt ) ; -: send ( obj -- ) ; - -\ send soft "break-after" set-word-prop - -: final-soft-break-test ( -- str ) - { - "USING: kernel sequences ;" - "IN: prettyprint.tests" - ": final-soft-break-layout ( class dim -- view )" - " [ \"alloc\" send 0 0 ] dip first2 " - " \"initWithFrame:pixelFormat:\" send" - " dup 1 \"setPostsBoundsChangedNotifications:\" send" - " dup 1 \"setPostsFrameChangedNotifications:\" send ;" - } ; - -[ t ] [ - "final-soft-break-layout" final-soft-break-test check-see -] unit-test - : narrow-test ( -- str ) { "USING: arrays combinators continuations kernel sequences ;" diff --git a/core/bootstrap/syntax.factor b/core/bootstrap/syntax.factor index 6e6812e25c..a0b349be51 100644 --- a/core/bootstrap/syntax.factor +++ b/core/bootstrap/syntax.factor @@ -62,6 +62,7 @@ IN: bootstrap.syntax "W{" "[" "\\" + "M\\" "]" "delimiter" "f" diff --git a/core/syntax/syntax-docs.factor b/core/syntax/syntax-docs.factor index df9eb568f6..bb8791df97 100644 --- a/core/syntax/syntax-docs.factor +++ b/core/syntax/syntax-docs.factor @@ -167,6 +167,8 @@ $nl ARTICLE: "syntax" "Syntax" "Factor has two main forms of syntax: " { $emphasis "definition" } " syntax and " { $emphasis "literal" } " syntax. Code is data, so the syntax for code is a special case of object literal syntax. This section documents literal syntax. Definition syntax is covered in " { $link "words" } ". Extending the parser is the main topic of " { $link "parser" } "." { $subsection "parser-algorithm" } +{ $subsection "vocabulary-search" } +{ $subsection "top-level-forms" } { $subsection "syntax-comments" } { $subsection "syntax-literals" } { $subsection "syntax-immediate" } ; @@ -762,7 +764,9 @@ HELP: >> { $description "Marks the end of a parse time code block." } ; HELP: call-next-method +{ $syntax "call-next-method" } { $description "Calls the next applicable method. Only valid inside a method definition. The values at the top of the stack are passed on to the next method, and they must be compatible with that method's class specializer." } +{ $notes "This word looks like an ordinary word but it is a parsing word. It cannot be factored out of a method definition, since the code expansion references the current method object directly." } { $errors "Throws a " { $link no-next-method } " error if this is the least specific method, and throws an " { $link inconsistent-next-method } " error if the values at the top of the stack are not compatible with the current method's specializer." } ; diff --git a/core/syntax/syntax.factor b/core/syntax/syntax.factor index cb5cdfd5ac..2e072f72d8 100644 --- a/core/syntax/syntax.factor +++ b/core/syntax/syntax.factor @@ -104,6 +104,7 @@ IN: bootstrap.syntax "POSTPONE:" [ scan-word parsed ] define-core-syntax "\\" [ scan-word parsed ] define-core-syntax + "M\\" [ scan-word scan-word method parsed ] define-core-syntax "inline" [ word make-inline ] define-core-syntax "recursive" [ word make-recursive ] define-core-syntax "foldable" [ word make-foldable ] define-core-syntax From 268abfcf2a389104a47e4f2174af4482de94b50f Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 6 Apr 2009 02:59:59 -0500 Subject: [PATCH 11/20] Remove method-specs in favor of M\ --- basis/compiler/tree/debugger/debugger.factor | 2 -- basis/editors/editors-docs.factor | 2 +- basis/hints/hints.factor | 5 ++-- basis/see/see-docs.factor | 7 +++++- basis/see/see.factor | 6 ----- basis/tools/annotations/annotations.factor | 11 +-------- basis/tools/deploy/shaker/shaker.factor | 2 -- basis/tools/disassembler/disassembler.factor | 2 -- core/generic/generic.factor | 26 -------------------- 9 files changed, 10 insertions(+), 53 deletions(-) diff --git a/basis/compiler/tree/debugger/debugger.factor b/basis/compiler/tree/debugger/debugger.factor index 430424291e..8e102e0ea3 100644 --- a/basis/compiler/tree/debugger/debugger.factor +++ b/basis/compiler/tree/debugger/debugger.factor @@ -130,8 +130,6 @@ M: node node>quot drop ; GENERIC: optimized. ( quot/word -- ) -M: method-spec optimized. first2 method optimized. ; - M: word optimized. specialized-def optimized. ; M: callable optimized. build-tree optimize-tree nodes>quot . ; diff --git a/basis/editors/editors-docs.factor b/basis/editors/editors-docs.factor index 0f50e40eb4..e3961aef80 100644 --- a/basis/editors/editors-docs.factor +++ b/basis/editors/editors-docs.factor @@ -22,7 +22,7 @@ HELP: edit "A word's documentation:" { $code "\\ foo >link edit" } "A method definition:" - { $code "{ editor draw-gadget* } edit" } + { $code "M\\ fixnum + edit" } "A help article:" { $code "\"handbook\" >link edit" } } ; diff --git a/basis/hints/hints.factor b/basis/hints/hints.factor index 804ef035f4..6fece31d88 100644 --- a/basis/hints/hints.factor +++ b/basis/hints/hints.factor @@ -65,7 +65,6 @@ M: object specializer-declaration class ; SYNTAX: HINTS: scan-object - dup method-spec? [ first2 method ] when [ redefined ] [ parse-definition "specializer" set-word-prop ] bi ; @@ -119,6 +118,6 @@ SYNTAX: HINTS: \ >be { { bignum fixnum } { fixnum fixnum } } "specializer" set-word-prop -\ hashtable \ at* method { { fixnum object } { word object } } "specializer" set-word-prop +M\ hashtable at* { { fixnum object } { word object } } "specializer" set-word-prop -\ hashtable \ set-at method { { object fixnum object } { object word object } } "specializer" set-word-prop +M\ hashtable set-at { { object fixnum object } { object word object } } "specializer" set-word-prop diff --git a/basis/see/see-docs.factor b/basis/see/see-docs.factor index 6d51b42a86..b2e99843c7 100644 --- a/basis/see/see-docs.factor +++ b/basis/see/see-docs.factor @@ -13,7 +13,12 @@ HELP: synopsis* HELP: see { $values { "defspec" "a definition specifier" } } -{ $contract "Prettyprints a definition." } ; +{ $contract "Prettyprints a definition." } +{ $examples + "A word:" { $code "\\ append see" } + "A method:" { $code "USE: arrays" "M\\ array length see" } + "A help article:" { $code "USE: help.topics" "\"help\" >link see" } +} ; HELP: see-methods { $values { "word" "a " { $link generic } " or a " { $link class } } } diff --git a/basis/see/see.factor b/basis/see/see.factor index 9fc14ff581..2494c72fa4 100644 --- a/basis/see/see.factor +++ b/basis/see/see.factor @@ -76,9 +76,6 @@ M: hook-generic synopsis* [ stack-effect. ] } cleave ; -M: method-spec synopsis* - first2 method synopsis* ; - M: method-body synopsis* [ definer. ] [ "method-class" word-prop pprint-word ] @@ -122,9 +119,6 @@ M: object see* block> ] with-use ; -M: method-spec see* - first2 method see* ; - GENERIC: see-class* ( word -- ) M: union-class see-class* diff --git a/basis/tools/annotations/annotations.factor b/basis/tools/annotations/annotations.factor index 8c3d95f2b8..64e6508ab6 100644 --- a/basis/tools/annotations/annotations.factor +++ b/basis/tools/annotations/annotations.factor @@ -20,9 +20,6 @@ M: word reset f "unannotated-def" set-word-prop ] [ drop ] if ; -M: method-spec reset - first2 method reset ; - ERROR: cannot-annotate-twice word ; word ( obj -- word ) - dup method-spec? [ first2 method ] when ; - : save-unannotated-def ( word -- ) dup def>> "unannotated-def" set-word-prop ; @@ -44,7 +38,7 @@ ERROR: cannot-annotate-twice word ; PRIVATE> : annotate ( word quot -- ) - [ method-spec>word check-annotate-twice ] dip + [ check-annotate-twice ] dip [ over save-unannotated-def (annotate) ] with-compilation-unit ; spaces print ] each ; M: word disassemble word-xt 2array disassemble ; -M: method-spec disassemble first2 method disassemble ; - cpu x86? "tools.disassembler.udis" "tools.disassembler.gdb" ? diff --git a/core/generic/generic.factor b/core/generic/generic.factor index c22641d439..ab0685f1d6 100644 --- a/core/generic/generic.factor +++ b/core/generic/generic.factor @@ -24,11 +24,6 @@ M: generic definition drop f ; : method ( class generic -- method/f ) "methods" word-prop at ; -PREDICATE: method-spec < pair - first2 generic? swap class? and ; - -INSTANCE: method-spec definition - : order ( generic -- seq ) "methods" word-prop keys sort-classes ; @@ -90,9 +85,6 @@ TUPLE: check-method class generic ; PREDICATE: method-body < word "method-generic" word-prop >boolean ; -M: method-spec stack-effect - first2 method stack-effect ; - M: method-body stack-effect "method-generic" word-prop stack-effect ; @@ -139,24 +131,6 @@ M: default-method irrelevant? drop t ; dupd "default-method" set-word-prop ; ! Definition protocol -M: method-spec where - dup first2 method [ ] [ second ] ?if where ; - -M: method-spec set-where - first2 method set-where ; - -M: method-spec definer - first2 method definer ; - -M: method-spec definition - first2 method definition ; - -M: method-spec forget* - first2 method [ forgotten-definition ] [ forget* ] bi ; - -M: method-spec smart-usage - second smart-usage ; - M: method-body definer drop \ M: \ ; ; From 99b8400e56e23584db5544e3b3cb64357721ec31 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 6 Apr 2009 03:00:46 -0500 Subject: [PATCH 12/20] Documentation updates --- basis/alien/syntax/tags.txt | 1 + .../combinators/short-circuit/smart/tags.txt | 1 + basis/combinators/short-circuit/tags.txt | 1 + basis/combinators/smart/smart-docs.factor | 14 +- basis/combinators/smart/tags.txt | 1 + basis/help/cookbook/cookbook.factor | 2 +- basis/help/handbook/handbook.factor | 89 +++-- basis/help/home/home-docs.factor | 1 - basis/help/syntax/tags.txt | 1 + basis/interpolate/tags.txt | 1 + basis/locals/locals-docs.factor | 11 +- basis/math/ranges/ranges-docs.factor | 4 +- basis/peg/ebnf/tags.txt | 1 + basis/ui/tools/tools-docs.factor | 4 +- basis/unicode/unicode-docs.factor | 2 +- basis/values/values-docs.factor | 2 +- basis/xml/syntax/tags.txt | 1 + core/combinators/combinators-docs.factor | 315 ++++++++++++++++-- core/definitions/definitions-docs.factor | 15 +- core/effects/effects-docs.factor | 15 +- core/generic/generic-docs.factor | 13 +- core/generic/generic-tests.factor | 3 - core/generic/math/math-docs.factor | 2 +- core/kernel/kernel-docs.factor | 285 ---------------- core/math/math-docs.factor | 5 +- core/math/order/order-docs.factor | 11 +- core/namespaces/namespaces-docs.factor | 3 +- core/parser/parser-docs.factor | 2 - core/quotations/quotations-docs.factor | 2 +- core/sequences/sequences-docs.factor | 11 +- core/slots/slots-docs.factor | 5 +- extra/peg-lexer/tags.txt | 3 +- 32 files changed, 440 insertions(+), 387 deletions(-) create mode 100644 basis/alien/syntax/tags.txt create mode 100644 basis/combinators/short-circuit/smart/tags.txt create mode 100644 basis/combinators/short-circuit/tags.txt create mode 100644 basis/combinators/smart/tags.txt create mode 100644 basis/help/syntax/tags.txt create mode 100644 basis/interpolate/tags.txt diff --git a/basis/alien/syntax/tags.txt b/basis/alien/syntax/tags.txt new file mode 100644 index 0000000000..f4274299b1 --- /dev/null +++ b/basis/alien/syntax/tags.txt @@ -0,0 +1 @@ +extensions diff --git a/basis/combinators/short-circuit/smart/tags.txt b/basis/combinators/short-circuit/smart/tags.txt new file mode 100644 index 0000000000..f4274299b1 --- /dev/null +++ b/basis/combinators/short-circuit/smart/tags.txt @@ -0,0 +1 @@ +extensions diff --git a/basis/combinators/short-circuit/tags.txt b/basis/combinators/short-circuit/tags.txt new file mode 100644 index 0000000000..f4274299b1 --- /dev/null +++ b/basis/combinators/short-circuit/tags.txt @@ -0,0 +1 @@ +extensions diff --git a/basis/combinators/smart/smart-docs.factor b/basis/combinators/smart/smart-docs.factor index 75f83c1a55..679b587759 100644 --- a/basis/combinators/smart/smart-docs.factor +++ b/basis/combinators/smart/smart-docs.factor @@ -108,17 +108,19 @@ HELP: append-outputs-as ARTICLE: "combinators.smart" "Smart combinators" -"The " { $vocab-link "combinators.smart" } " vocabulary implements " { $emphasis "smart combinators" } ". A smart combinator is one whose behavior depends on the static stack effect of an input quotation." $nl -"Smart inputs from a sequence:" +"The macros in the " { $vocab-link "combinators.smart" } " vocabulary look at the static stack effects of input quotations and generate code which produces or consumes the relevant number of stack values." $nl +"Call a quotation and discard all output values:" +{ $subsection drop-outputs } +"Take all input values from a sequence:" { $subsection inputsequence } { $subsection output>array } -"Reducing the output of a quotation:" +"Reducing the set of output values:" { $subsection reduce-outputs } -"Summing the output of a quotation:" +"Summing output values:" { $subsection sum-outputs } -"Appending the results of a quotation:" +"Concatenating output values:" { $subsection append-outputs } { $subsection append-outputs-as } ; diff --git a/basis/combinators/smart/tags.txt b/basis/combinators/smart/tags.txt new file mode 100644 index 0000000000..f4274299b1 --- /dev/null +++ b/basis/combinators/smart/tags.txt @@ -0,0 +1 @@ +extensions diff --git a/basis/help/cookbook/cookbook.factor b/basis/help/cookbook/cookbook.factor index 2cc19f87dd..867f373209 100644 --- a/basis/help/cookbook/cookbook.factor +++ b/basis/help/cookbook/cookbook.factor @@ -117,7 +117,7 @@ $nl } { $references { "Since quotations are objects, they can be constructed and taken apart at will. You can write code that writes code. Arrays are just one of the various types of sequences, and the sequence operations such as " { $link each } " and " { $link map } " operate on all types of sequences. There are many more sequence iteration operations than the ones above, too." } - "dataflow" + "combinators" "sequences" } ; diff --git a/basis/help/handbook/handbook.factor b/basis/help/handbook/handbook.factor index ed2a14a2f2..b2a0e56c0a 100644 --- a/basis/help/handbook/handbook.factor +++ b/basis/help/handbook/handbook.factor @@ -5,7 +5,7 @@ math system strings sbufs vectors byte-arrays quotations io.streams.byte-array classes.builtin parser lexer classes.predicate classes.union classes.intersection classes.singleton classes.tuple help.vocabs math.parser -accessors ; +accessors definitions ; IN: help.handbook ARTICLE: "conventions" "Conventions" @@ -49,7 +49,7 @@ $nl { "associative mapping" { "an object whose class implements the " { $link "assocs-protocol" } } } { "boolean" { { $link t } " or " { $link f } } } { "class" { "a set of objects identified by a " { $emphasis "class word" } " together with a discriminating predicate. See " { $link "classes" } } } - { "definition specifier" { "a " { $link word } ", " { $link method-spec } ", " { $link link } ", vocabulary specifier, or any other object whose class implements the " { $link "definition-protocol" } } } + { "definition specifier" { "an instance of " { $link definition } " which implements the " { $link "definition-protocol" } } } { "generalized boolean" { "an object interpreted as a boolean; a value of " { $link f } " denotes false and anything else denotes true" } } { "generic word" { "a word whose behavior depends can be specialized on the class of one of its inputs. See " { $link "generic" } } } { "method" { "a specialized behavior of a generic word on a class. See " { $link "generic" } } } @@ -70,7 +70,7 @@ ARTICLE: "tail-call-opt" "Tail-call optimization" $nl "Tail-call optimization allows iterative algorithms to be implemented in an efficient manner using recursion, without the need for any kind of primitive looping construct in the language. However, in practice, most iteration is performed via combinators such as " { $link while } ", " { $link each } ", " { $link map } ", " { $link assoc-each } ", and so on. The definitions of these combinators do bottom-out in recursive words, however." ; -ARTICLE: "evaluator" "Evaluation semantics" +ARTICLE: "evaluator" "Stack machine model" { $link "quotations" } " are evaluated sequentially from beginning to end. When the end is reached, the quotation returns to its caller. As each object in the quotation is evaluated in turn, an action is taken based on its type:" { $list { "a " { $link word } " - the word's definition quotation is called. See " { $link "words" } } @@ -84,12 +84,13 @@ ARTICLE: "objects" "Objects" "An " { $emphasis "object" } " is any datum which may be identified. All values are objects in Factor. Each object carries type information, and types are checked at runtime; Factor is dynamically typed." { $subsection "equality" } { $subsection "math.order" } -{ $subsection "destructors" } { $subsection "classes" } { $subsection "tuples" } { $subsection "generic" } -{ $subsection "slots" } -{ $subsection "mirrors" } ; +"Advanced features:" +{ $subsection "delegate" } +{ $subsection "mirrors" } +{ $subsection "slots" } ; ARTICLE: "numbers" "Numbers" { $subsection "arithmetic" } @@ -118,9 +119,9 @@ ARTICLE: "collections" "Collections" "Fixed-length sequences:" { $subsection "arrays" } { $subsection "quotations" } -"Fixed-length specialized sequences:" { $subsection "strings" } { $subsection "byte-arrays" } +{ $subsection "specialized-arrays" } "Resizable sequences:" { $subsection "vectors" } { $subsection "byte-vectors" } @@ -128,7 +129,8 @@ ARTICLE: "collections" "Collections" { $subsection "growable" } { $heading "Associative mappings" } { $subsection "assocs" } -{ $subsection "namespaces" } +{ $subsection "linked-assocs" } +{ $subsection "biassocs" } { $subsection "refs" } "Implementations:" { $subsection "hashtables" } @@ -140,26 +142,29 @@ ARTICLE: "collections" "Collections" { $subsection "dlists" } { $subsection "search-deques" } { $heading "Other collections" } -{ $subsection "boxes" } +{ $subsection "lists" } +{ $subsection "disjoint-sets" } +{ $subsection "interval-maps" } { $subsection "heaps" } +{ $subsection "boxes" } { $subsection "graphs" } { $subsection "buffers" } "There are also many other vocabularies tagged " { $link T{ vocab-tag { name "collections" } } } " in the library." ; -USING: io.encodings.utf8 io.encodings.utf16 io.encodings.binary io.encodings.ascii io.files ; +USING: io.encodings.utf8 io.encodings.binary io.files ; ARTICLE: "encodings-introduction" "An introduction to encodings" "In order to express text in terms of binary, some sort of encoding has to be used. In a modern context, this is understood as a two-way mapping between Unicode code points (characters) and some amount of binary. Since English isn't the only language in the world, ASCII is not sufficient as a mapping from binary to Unicode; it can't even express em-dashes or curly quotes. Unicode was designed as a universal character set that could potentially represent everything." $nl "Not all encodings can represent all Unicode code points, but Unicode can represent basically everything that exists in modern encodings. Some encodings are language-specific, and some can represent everything in Unicode. Though the world is moving toward Unicode and UTF-8, the reality today is that there are several encodings which must be taken into account." $nl -"Factor uses a system of encoding descriptors to denote encodings. Encoding descriptors are objects which describe encodings. Examples are " { $link utf8 } ", " { $link ascii } " and " { $link binary } ". Encoding descriptors can be passed around independently. Each encoding descriptor has some method for constructing an encoded or decoded stream, and the resulting stream has an encoding descriptor stored which has methods for reading or writing characters." $nl +"Factor uses a system of encoding descriptors to denote encodings. Encoding descriptors are objects which describe encodings. Examples are " { $link utf8 } " and " { $link binary } ". Encoding descriptors can be passed around independently. Each encoding descriptor has some method for constructing an encoded or decoded stream, and the resulting stream has an encoding descriptor stored which has methods for reading or writing characters." $nl "Constructors for streams which deal with bytes usually take an encoding as an explicit parameter. For example, to open a text file for reading whose contents are in UTF-8, use the following" { $code "\"file.txt\" utf8 " } "If there is an error in the encoded stream, a replacement character (0xFFFD) will be inserted. To throw an exception upon error, use a strict encoding as follows" { $code "\"file.txt\" utf8 strict " } "In a similar way, encodings can be specified when opening a file for writing." -{ $code "\"file.txt\" ascii " } +{ $code "USE: io.encodings.ascii" "\"file.txt\" ascii " } "An encoding is also needed for some words that don't return streams, such as " { $link file-contents } ", for example" -{ $code "\"file.txt\" utf16 file-contents" } +{ $code "USE: io.encodings.utf16" "\"file.txt\" utf16 file-contents" } "Encoding descriptors are also used by " { $link "io.streams.byte-array" } " and taken by combinators like " { $link with-file-writer } " and " { $link with-byte-reader } " which deal with streams. It is " { $emphasis "not" } " used with " { $link "io.streams.string" } " because these deal with abstract text." $nl "When the " { $link binary } " encoding is used, a " { $link byte-array } " is expected for writing and returned for reading, since the stream deals with bytes. All other encodings deal with strings, since they are used to represent text." ; @@ -239,40 +244,57 @@ ARTICLE: "class-index" "Class index" { $heading "Predicate classes" } { $index [ classes [ predicate-class? ] filter ] } ; -ARTICLE: "program-org" "Program organization" -{ $subsection "definitions" } -{ $subsection "vocabularies" } -{ $subsection "parser" } -{ $subsection "vocabs.loader" } -{ $subsection "source-files" } ; - USING: help.cookbook help.tutorial ; ARTICLE: "handbook-language-reference" "Language reference" +"Fundamentals:" { $subsection "conventions" } { $subsection "syntax" } -{ $subsection "dataflow" } -{ $subsection "objects" } -{ $subsection "program-org" } +{ $subsection "effects" } +"Data types:" +{ $subsection "booleans" } { $subsection "numbers" } { $subsection "collections" } -{ $subsection "io" } +"Evaluation semantics:" +{ $subsection "evaluator" } +{ $subsection "words" } +{ $subsection "shuffle-words" } +{ $subsection "combinators" } +{ $subsection "errors" } +{ $subsection "continuations" } +"Named values:" +{ $subsection "locals" } +{ $subsection "namespaces" } +{ $subsection "namespaces-global" } +{ $subsection "values" } +"Abstractions:" +{ $subsection "objects" } +{ $subsection "destructors" } +{ $subsection "macros" } +{ $subsection "fry" } +"Program organization:" +{ $subsection "vocabs.loader" } "Vocabularies tagged " { $link T{ vocab-tag { name "extensions" } } } " implement various additional language abstractions." ; ARTICLE: "handbook-environment-reference" "Environment reference" +"Parse time and compile time:" +{ $subsection "parser" } +{ $subsection "definitions" } +{ $subsection "vocabularies" } +{ $subsection "source-files" } +{ $subsection "compiler" } +"Tools:" { $subsection "prettyprint" } { $subsection "tools" } -{ $subsection "cli" } -{ $subsection "rc-files" } { $subsection "help" } { $subsection "inference" } -{ $subsection "compiler" } -{ $subsection "system" } { $subsection "images" } -{ $subsection "alien" } +"VM:" +{ $subsection "cli" } +{ $subsection "rc-files" } { $subsection "init" } -{ $subsection "layouts" } -{ $see-also "program-org" } ; +{ $subsection "system" } +{ $subsection "layouts" } ; ARTICLE: "handbook-library-reference" "Library reference" "This index only includes articles from loaded vocabularies. To explore more vocabularies, see " { $link "vocab-index" } "." @@ -282,9 +304,14 @@ ARTICLE: "handbook" "Factor handbook" "Learn the language:" { $subsection "cookbook" } { $subsection "first-program" } +"Reference material:" { $subsection "handbook-language-reference" } { $subsection "handbook-environment-reference" } +{ $subsection "io" } { $subsection "ui" } +{ $subsection "ui-tools" } +{ $subsection "unicode" } +{ $subsection "alien" } { $subsection "handbook-library-reference" } "Explore loaded libraries:" { $subsection "article-index" } diff --git a/basis/help/home/home-docs.factor b/basis/help/home/home-docs.factor index 6608a6e9c0..e6db2d3b9c 100644 --- a/basis/help/home/home-docs.factor +++ b/basis/help/home/home-docs.factor @@ -8,7 +8,6 @@ ARTICLE: "help.home" "Factor documentation" { $link "handbook" } { $link "vocab-index" } { $link "ui-tools" } - { $link "handbook-library-reference" } } { $heading "Recently visited" } { $table diff --git a/basis/help/syntax/tags.txt b/basis/help/syntax/tags.txt new file mode 100644 index 0000000000..f4274299b1 --- /dev/null +++ b/basis/help/syntax/tags.txt @@ -0,0 +1 @@ +extensions diff --git a/basis/interpolate/tags.txt b/basis/interpolate/tags.txt new file mode 100644 index 0000000000..f4274299b1 --- /dev/null +++ b/basis/interpolate/tags.txt @@ -0,0 +1 @@ +extensions diff --git a/basis/locals/locals-docs.factor b/basis/locals/locals-docs.factor index 18dabed4b0..b1f0b6ca17 100644 --- a/basis/locals/locals-docs.factor +++ b/basis/locals/locals-docs.factor @@ -112,7 +112,15 @@ HELP: MEMO:: { $description "Defines a memoized word with named inputs; it reads stack values into bindings from left to right, then executes the body with those bindings in lexical scope." } ; { POSTPONE: MEMO: POSTPONE: MEMO:: } related-words + +HELP: M:: +{ $syntax "M:: class generic ( bindings... -- outputs... ) body... ;" } +{ $description "Defines a method with named inputs; it reads stack values into bindings from left to right, then executes the body with those bindings in lexical scope." } +{ $notes "The output names do not affect the word's behavior, however the compiler attempts to check the stack effect as with other definitions." } ; +{ POSTPONE: M: POSTPONE: M:: } related-words + + ARTICLE: "locals-literals" "Locals in literals" "Certain data type literals are permitted to contain free variables. Any such literals are written into code which constructs an instance of the type with the free variable values spliced in. Conceptually, this is similar to the transformation applied to quotations containing free variables." $nl @@ -237,13 +245,14 @@ $nl } "The reason is that locals are rewritten into stack code at parse time, whereas macro expansion is performed later during compile time. To circumvent this problem, the " { $vocab-link "macros.expander" } " vocabulary is used to rewrite simple macro usages prior to local transformation, however "{ $vocab-link "macros.expander" } " does not deal with more complicated cases where the literal inputs to the macro do not immediately precede the macro call in the source." ; -ARTICLE: "locals" "Local variables and lexical closures" +ARTICLE: "locals" "Lexical variables and closures" "The " { $vocab-link "locals" } " vocabulary implements lexical scope with full closures, both downward and upward. Mutable bindings are supported, including assignment to bindings in outer scope." $nl "Compile-time transformation is used to compile local variables to efficient code; prettyprinter extensions are defined so that " { $link see } " can display original word definitions with local variables and not the closure-converted concatenative code which results." $nl "Applicative word definitions where the inputs are named local variables:" { $subsection POSTPONE: :: } +{ $subsection POSTPONE: M:: } { $subsection POSTPONE: MEMO:: } { $subsection POSTPONE: MACRO:: } "Lexical binding forms:" diff --git a/basis/math/ranges/ranges-docs.factor b/basis/math/ranges/ranges-docs.factor index 8987def80b..e35adb10e5 100644 --- a/basis/math/ranges/ranges-docs.factor +++ b/basis/math/ranges/ranges-docs.factor @@ -2,7 +2,7 @@ USING: help.syntax help.markup arrays sequences ; IN: math.ranges -ARTICLE: "ranges" "Ranges" +ARTICLE: "math.ranges" "Numeric ranges" "A " { $emphasis "range" } " is a virtual sequence with real number elements " "ranging from " { $emphasis "a" } " to " { $emphasis "b" } " by " { $emphasis "step" } ". Ascending as well as descending ranges are supported." $nl @@ -24,4 +24,4 @@ $nl { $code "100 1 [a,b] product" } "A range can be converted into a concrete sequence using a word such as " { $link >array } ". In most cases this is unnecessary since ranges implement the sequence protocol already. It is necessary if a mutable sequence is needed, for use with words such as " { $link set-nth } " or " { $link change-each } "." ; -ABOUT: "ranges" \ No newline at end of file +ABOUT: "math.ranges" \ No newline at end of file diff --git a/basis/peg/ebnf/tags.txt b/basis/peg/ebnf/tags.txt index 5af5dba748..1ccdafb2bb 100644 --- a/basis/peg/ebnf/tags.txt +++ b/basis/peg/ebnf/tags.txt @@ -1,2 +1,3 @@ +extensions text parsing diff --git a/basis/ui/tools/tools-docs.factor b/basis/ui/tools/tools-docs.factor index 93f45591a5..52cd77d726 100644 --- a/basis/ui/tools/tools-docs.factor +++ b/basis/ui/tools/tools-docs.factor @@ -55,7 +55,7 @@ $nl ARTICLE: "ui-tools" "UI developer tools" "The " { $vocab-link "ui.tools" } " vocabulary hierarchy implements a collection of simple developer tools." -$nl +{ $subsection "starting-ui-tools" } "To take full advantage of the UI tools, you should be using a supported text editor. See " { $link "editor" } "." $nl "Common functionality:" @@ -66,7 +66,7 @@ $nl { $subsection "ui-listener" } { $subsection "ui-browser" } { $subsection "ui-inspector" } -{ $subsection "ui-profiler" } +{ $subsection "ui.tools.profiler" } { $subsection "ui-walker" } { $subsection "ui.tools.deploy" } "Platform-specific features:" diff --git a/basis/unicode/unicode-docs.factor b/basis/unicode/unicode-docs.factor index 9450b49f0b..56432585c0 100644 --- a/basis/unicode/unicode-docs.factor +++ b/basis/unicode/unicode-docs.factor @@ -1,7 +1,7 @@ USING: help.markup help.syntax strings ; IN: unicode -ARTICLE: "unicode" "Unicode" +ARTICLE: "unicode" "Unicode support" "The " { $vocab-link "unicode" } " vocabulary and its sub-vocabularies implement support for the Unicode 5.1 character set." $nl "The Unicode character set contains most of the world's writing systems. Unicode is intended as a replacement for, and is a superset of, such legacy character sets as ASCII, Latin1, MacRoman, and so on. Unicode characters are called " { $emphasis "code points" } "; Factor's " { $link "strings" } " are sequences of code points." diff --git a/basis/values/values-docs.factor b/basis/values/values-docs.factor index df38869fbf..7c96f19ac9 100644 --- a/basis/values/values-docs.factor +++ b/basis/values/values-docs.factor @@ -2,7 +2,7 @@ USING: help.markup help.syntax ; IN: values ARTICLE: "values" "Global values" -"Usually, dynamically scoped variables are sufficient for holding data which is not literal. But occasionally, for global information that's calculated just once, it's useful to use the word mechanism instead, and set the word to the appropriate value just once. The " { $vocab-link "values" } " vocabulary implements " { $emphasis "values" } ", which abstract over this concept. To create a new word as a value, use the following syntax:" +"Usually, dynamically-scoped variables subsume global variables and are sufficient for holding global data. But occasionally, for global information that's calculated just once and must be accessed more rapidly than a dynamic variable lookup can provide, it's useful to use the word mechanism instead, and set a word to the appropriate value just once. The " { $vocab-link "values" } " vocabulary implements " { $emphasis "values" } ", which abstract over this concept. To create a new word as a value, use the following syntax:" { $subsection POSTPONE: VALUE: } "To get the value, just call the word. The following words manipulate values:" { $subsection get-value } diff --git a/basis/xml/syntax/tags.txt b/basis/xml/syntax/tags.txt index 71c0ff7282..4f4a20b1cb 100644 --- a/basis/xml/syntax/tags.txt +++ b/basis/xml/syntax/tags.txt @@ -1 +1,2 @@ +extensions syntax diff --git a/core/combinators/combinators-docs.factor b/core/combinators/combinators-docs.factor index cc502140ad..9c96fe34c9 100644 --- a/core/combinators/combinators-docs.factor +++ b/core/combinators/combinators-docs.factor @@ -4,46 +4,313 @@ math assocs sequences sequences.private combinators.private effects words ; IN: combinators +ARTICLE: "cleave-shuffle-equivalence" "Expressing shuffle words with cleave combinators" +"Cleave combinators are defined in terms of shuffle words, and mappings from certain shuffle idioms to cleave combinators are discussed in the documentation for " { $link bi } ", " { $link 2bi } ", " { $link 3bi } ", " { $link tri } ", " { $link 2tri } " and " { $link 3tri } "." +$nl +"Certain shuffle words can also be expressed in terms of the cleave combinators. Internalizing such identities can help with understanding and writing code using cleave combinators:" +{ $code + ": keep [ ] bi ;" + ": 2keep [ ] 2bi ;" + ": 3keep [ ] 3bi ;" + "" + ": dup [ ] [ ] bi ;" + ": 2dup [ ] [ ] 2bi ;" + ": 3dup [ ] [ ] 3bi ;" + "" + ": tuck [ nip ] [ ] 2bi ;" + ": swap [ nip ] [ drop ] 2bi ;" + "" + ": over [ ] [ drop ] 2bi ;" + ": pick [ ] [ 2drop ] 3bi ;" + ": 2over [ ] [ drop ] 3bi ;" +} ; + +ARTICLE: "cleave-combinators" "Cleave combinators" +"The cleave combinators apply multiple quotations to a single value." +$nl +"Two quotations:" +{ $subsection bi } +{ $subsection 2bi } +{ $subsection 3bi } +"Three quotations:" +{ $subsection tri } +{ $subsection 2tri } +{ $subsection 3tri } +"An array of quotations:" +{ $subsection cleave } +{ $subsection 2cleave } +{ $subsection 3cleave } +"Technically, the cleave combinators are redundant because they can be simulated using shuffle words and other combinators, and in addition, they do not reduce token counts by much, if at all. However, they can make code more readable by expressing intention and exploiting any inherent symmetry. For example, a piece of code which performs three operations on the top of the stack can be written in one of two ways:" +{ $code + "! First alternative; uses keep" + "[ 1 + ] keep" + "[ 1 - ] keep" + "2 *" + "! Second alternative: uses tri" + "[ 1 + ]" + "[ 1 - ]" + "[ 2 * ] tri" +} +"The latter is more aesthetically pleasing than the former." +{ $subsection "cleave-shuffle-equivalence" } ; + +ARTICLE: "spread-shuffle-equivalence" "Expressing shuffle words with spread combinators" +"Spread combinators are defined in terms of shuffle words, and mappings from certain shuffle idioms to spread combinators are discussed in the documentation for " { $link bi* } ", " { $link 2bi* } ", " { $link tri* } ", and " { $link 2tri* } "." +$nl +"Certain shuffle words can also be expressed in terms of the spread combinators. Internalizing such identities can help with understanding and writing code using spread combinators:" +{ $code + ": dip [ ] bi* ;" + ": 2dip [ ] [ ] tri* ;" + "" + ": slip [ call ] [ ] bi* ;" + ": 2slip [ call ] [ ] [ ] tri* ;" + "" + ": nip [ drop ] [ ] bi* ;" + ": 2nip [ drop ] [ drop ] [ ] tri* ;" + "" + ": rot" + " [ [ drop ] [ ] [ drop ] tri* ]" + " [ [ drop ] [ drop ] [ ] tri* ]" + " [ [ ] [ drop ] [ drop ] tri* ]" + " 3tri ;" + "" + ": -rot" + " [ [ drop ] [ drop ] [ ] tri* ]" + " [ [ ] [ drop ] [ drop ] tri* ]" + " [ [ drop ] [ ] [ drop ] tri* ]" + " 3tri ;" + "" + ": spin" + " [ [ drop ] [ drop ] [ ] tri* ]" + " [ [ drop ] [ ] [ drop ] tri* ]" + " [ [ ] [ drop ] [ drop ] tri* ]" + " 3tri ;" +} ; + +ARTICLE: "spread-combinators" "Spread combinators" +"The spread combinators apply multiple quotations to multiple values. The " { $snippet "*" } " suffix signifies spreading." +$nl +"Two quotations:" +{ $subsection bi* } +{ $subsection 2bi* } +"Three quotations:" +{ $subsection tri* } +{ $subsection 2tri* } +"An array of quotations:" +{ $subsection spread } +"Technically, the spread combinators are redundant because they can be simulated using shuffle words and other combinators, and in addition, they do not reduce token counts by much, if at all. However, they can make code more readable by expressing intention and exploiting any inherent symmetry. For example, a piece of code which performs three operations on three related values can be written in one of two ways:" +{ $code + "! First alternative; uses dip" + "[ [ 1 + ] dip 1 - ] dip 2 *" + "! Second alternative: uses tri*" + "[ 1 + ] [ 1 - ] [ 2 * ] tri*" +} +"A generalization of the above combinators to any number of quotations can be found in " { $link "combinators" } "." +{ $subsection "spread-shuffle-equivalence" } ; + +ARTICLE: "apply-combinators" "Apply combinators" +"The apply combinators apply a single quotation to multiple values. The " { $snippet "@" } " suffix signifies application." +$nl +"Two quotations:" +{ $subsection bi@ } +{ $subsection 2bi@ } +"Three quotations:" +{ $subsection tri@ } +{ $subsection 2tri@ } +"A pair of utility words built from " { $link bi@ } ":" +{ $subsection both? } +{ $subsection either? } ; + +ARTICLE: "slip-keep-combinators" "Retain stack combinators" +"Sometimes an additional storage area is needed to hold objects. The " { $emphasis "retain stack" } " is an auxilliary stack for this purpose. Objects can be moved between the data and retain stacks using a set of combinators." +$nl +"The dip combinators invoke the quotation at the top of the stack, hiding the values underneath:" +{ $subsection dip } +{ $subsection 2dip } +{ $subsection 3dip } +{ $subsection 4dip } +"The slip combinators invoke a quotation further down on the stack. They are most useful for implementing other combinators:" +{ $subsection slip } +{ $subsection 2slip } +{ $subsection 3slip } +"The keep combinators invoke a quotation which takes a number of values off the stack, and then they restore those values:" +{ $subsection keep } +{ $subsection 2keep } +{ $subsection 3keep } ; + +ARTICLE: "curried-dataflow" "Curried dataflow combinators" +"Curried cleave combinators:" +{ $subsection bi-curry } +{ $subsection tri-curry } +"Curried spread combinators:" +{ $subsection bi-curry* } +{ $subsection tri-curry* } +"Curried apply combinators:" +{ $subsection bi-curry@ } +{ $subsection tri-curry@ } +{ $see-also "dataflow-combinators" } ; + +ARTICLE: "compositional-examples" "Examples of compositional combinator usage" +"Consider printing the same message ten times:" +{ $code ": print-10 ( -- ) 10 [ \"Hello, world.\" print ] times ;" } +"if we wanted to abstract out the message into a parameter, we could keep it on the stack between iterations:" +{ $code ": print-10 ( message -- ) 10 [ dup print ] times drop ;" } +"However, keeping loop-invariant values on the stack doesn't always work out nicely. For example, a word to subtract a value from each element of a sequence:" +{ $code ": subtract-n ( seq n -- seq' ) swap [ over - ] map nip ;" } +"Three shuffle words are required to pass the value around. Instead, the loop-invariant value can be partially applied to a quotation using " { $link curry } ", yielding a new quotation that is passed to " { $link map } ":" +{ $example + "USING: kernel math prettyprint sequences ;" + ": subtract-n ( seq n -- seq' ) [ - ] curry map ;" + "{ 10 20 30 } 5 subtract-n ." + "{ 5 15 25 }" +} +"Now consider the word that is dual to the one above; instead of subtracting " { $snippet "n" } " from each stack element, it subtracts each element from " { $snippet "n" } "." +$nl +"One way to write this is with a pair of " { $link swap } "s:" +{ $code ": n-subtract ( n seq -- seq' ) swap [ swap - ] curry map ;" } +"Since this pattern comes up often, " { $link with } " encapsulates it:" +{ $example + "USING: kernel math prettyprint sequences ;" + ": n-subtract ( n seq -- seq' ) [ - ] with map ;" + "30 { 10 20 30 } n-subtract ." + "{ 20 10 0 }" +} +{ $see-also "fry.examples" } ; + +ARTICLE: "compositional-combinators" "Compositional combinators" +"Certain combinators transform quotations to produce a new quotation." +{ $subsection "compositional-examples" } +"Fundamental operations:" +{ $subsection curry } +{ $subsection compose } +"Derived operations:" +{ $subsection 2curry } +{ $subsection 3curry } +{ $subsection with } +{ $subsection prepose } +"These operations run in constant time, and in many cases are optimized out altogether by the " { $link "compiler" } ". " { $link "fry" } " are an abstraction built on top of these operations, and code that uses this abstraction is often clearer than direct calls to the below words." +$nl +"Curried dataflow combinators can be used to build more complex dataflow by combining cleave, spread and apply patterns in various ways." +{ $subsection "curried-dataflow" } +"Quotations also implement the sequence protocol, and can be manipulated with sequence words; see " { $link "quotations" } ". However, such runtime quotation manipulation will not be optimized by the optimizing compiler." ; + +ARTICLE: "booleans" "Booleans" +"In Factor, any object that is not " { $link f } " has a true value, and " { $link f } " has a false value. The " { $link t } " object is the canonical true value." +{ $subsection f } +{ $subsection t } +"There are some logical operations on booleans:" +{ $subsection >boolean } +{ $subsection not } +{ $subsection and } +{ $subsection or } +{ $subsection xor } +"Boolean values are most frequently used for " { $link "conditionals" } "." +{ $heading "The f object and f class" } +"The " { $link f } " object is the unique instance of the " { $link f } " class; the two are distinct objects. The latter is also a parsing word which adds the " { $link f } " object to the parse tree at parse time. To refer to the class itself you must use " { $link POSTPONE: POSTPONE: } " or " { $link POSTPONE: \ } " to prevent the parsing word from executing." +$nl +"Here is the " { $link f } " object:" +{ $example "f ." "f" } +"Here is the " { $link f } " class:" +{ $example "\\ f ." "POSTPONE: f" } +"They are not equal:" +{ $example "f \\ f = ." "f" } +"Here is an array containing the " { $link f } " object:" +{ $example "{ f } ." "{ f }" } +"Here is an array containing the " { $link f } " class:" +{ $example "{ POSTPONE: f } ." "{ POSTPONE: f }" } +"The " { $link f } " object is an instance of the " { $link f } " class:" +{ $example "USE: classes" "f class ." "POSTPONE: f" } +"The " { $link f } " class is an instance of " { $link word } ":" +{ $example "USE: classes" "\\ f class ." "word" } +"On the other hand, " { $link t } " is just a word, and there is no class which it is a unique instance of." +{ $example "t \\ t eq? ." "t" } +"Many words which search collections confuse the case of no element being present with an element being found equal to " { $link f } ". If this distinction is imporant, there is usually an alternative word which can be used; for example, compare " { $link at } " with " { $link at* } "." ; + +ARTICLE: "conditionals-boolean-equivalence" "Expressing conditionals with boolean logic" +"Certain simple conditional forms can be expressed in a simpler manner using boolean logic." +$nl +"The following two lines are equivalent:" +{ $code "[ drop f ] unless" "swap and" } +"The following two lines are equivalent:" +{ $code "[ ] [ ] ?if" "swap or" } +"The following two lines are equivalent, where " { $snippet "L" } " is a literal:" +{ $code "[ L ] unless*" "L or" } ; + +ARTICLE: "conditionals" "Conditional combinators" +"The basic conditionals:" +{ $subsection if } +{ $subsection when } +{ $subsection unless } +"Forms abstracting a common stack shuffle pattern:" +{ $subsection if* } +{ $subsection when* } +{ $subsection unless* } +"Another form abstracting a common stack shuffle pattern:" +{ $subsection ?if } +"Sometimes instead of branching, you just need to pick one of two values:" +{ $subsection ? } +"Two combinators which abstract out nested chains of " { $link if } ":" +{ $subsection cond } +{ $subsection case } +{ $subsection "conditionals-boolean-equivalence" } +{ $see-also "booleans" "bitwise-arithmetic" both? either? } ; + +ARTICLE: "dataflow-combinators" "Data flow combinators" +"Data flow combinators pass values between quotations:" +{ $subsection "slip-keep-combinators" } +{ $subsection "cleave-combinators" } +{ $subsection "spread-combinators" } +{ $subsection "apply-combinators" } +{ $see-also "curried-dataflow" } ; + ARTICLE: "combinators-quot" "Quotation construction utilities" "Some words for creating quotations which can be useful for implementing method combinations and compiler transforms:" { $subsection cond>quot } { $subsection case>quot } { $subsection alist>quot } ; -ARTICLE: "call" "Calling code with known stack effects" -"Arbitrary quotations and words can be called from code accepted by the optimizing compiler. This is done by specifying the stack effect of the quotation literally. It is checked at runtime that the stack effect is accurate." +ARTICLE: "call" "Fundamental combinators" +"The most basic combinators are those that take either a quotation or word, and invoke it immediately. There are two sets of combinators; they differe in whether or not the stack effect of the expected code is declared." $nl -"Quotations:" -{ $subsection POSTPONE: call( } +"The simplest combinators do not take an effect declaration:" +{ $subsection call } +{ $subsection execute } +"These combinators only get optimized by the compiler if the quotation or word parameter is a literal; otherwise a compiler warning will result. Definitions of combinators which require literal parameters must be followed by the " { $link POSTPONE: inline } " declaration. For example:" +{ $code + ": keep ( x quot -- x )" + " over [ call ] dip ; inline" +} +"See " { $link "declarations" } " and " { $link "compiler-errors" } " for details." +$nl +"The other set of combinators allow arbitrary quotations and words to be called from optimized code. This is done by specifying the stack effect of the quotation literally. It is checked at runtime that the stack effect is accurate." { $subsection call-effect } -"Words:" -{ $subsection POSTPONE: execute( } { $subsection execute-effect } -"Unsafe calls:" +"A simple layer of syntax sugar is defined on top:" +{ $subsection POSTPONE: call( } +{ $subsection POSTPONE: execute( } +"Unsafe calls declare an effect statically without any runtime checking:" { $subsection call-effect-unsafe } -{ $subsection execute-effect-unsafe } ; +{ $subsection execute-effect-unsafe } +{ $see-also "effects" "inference" } ; -ARTICLE: "combinators" "Additional combinators" -"The " { $vocab-link "combinators" } " vocabulary provides a few useful combinators." +ARTICLE: "combinators" "Combinators" +"A central concept in Factor is that of a " { $emphasis "combinator" } ", which is a word taking code as input." +{ $subsection "call" } +{ $subsection "dataflow-combinators" } +{ $subsection "conditionals" } +{ $subsection "looping-combinators" } +{ $subsection "compositional-combinators" } +{ $subsection "combinators.short-circuit" } +{ $subsection "combinators.smart" } +"More combinators are defined for working on data structures, such as " { $link "sequences-combinators" } " and " { $link "assocs-combinators" } "." $nl -"Generalization of " { $link bi } " and " { $link tri } ":" -{ $subsection cleave } -"Generalization of " { $link 2bi } " and " { $link 2tri } ":" -{ $subsection 2cleave } -"Generalization of " { $link 3bi } " and " { $link 3tri } ":" -{ $subsection 3cleave } -"Generalization of " { $link bi* } " and " { $link tri* } ":" -{ $subsection spread } -"Two combinators which abstract out nested chains of " { $link if } ":" -{ $subsection cond } -{ $subsection case } -"The " { $vocab-link "combinators" } " also provides some less frequently-used features." +"The " { $vocab-link "combinators" } " provides some less frequently-used features." $nl "A combinator which can help with implementing methods on " { $link hashcode* } ":" { $subsection recursive-hashcode } -{ $subsection "call" } { $subsection "combinators-quot" } -{ $see-also "quotations" "dataflow" } ; +"Advanced topics:" +{ $see-also "quotations" } ; ABOUT: "combinators" diff --git a/core/definitions/definitions-docs.factor b/core/definitions/definitions-docs.factor index b53ab28cbc..9d49cf62c6 100644 --- a/core/definitions/definitions-docs.factor +++ b/core/definitions/definitions-docs.factor @@ -56,11 +56,24 @@ $nl { $subsection redefine-error } ; ARTICLE: "definitions" "Definitions" -"A " { $emphasis "definition" } " is an artifact read from a source file. This includes words, methods, help articles, and path names (which represent the source file at that location). Words for working with definitions are found in the " { $vocab-link "definitions" } " vocabulary." +"A " { $emphasis "definition" } " is an artifact read from a source file. Words for working with definitions are found in the " { $vocab-link "definitions" } " vocabulary." +$nl +"Definitions are defined using parsing words. Examples of definitions together with their defining parsing words are words (" { $link POSTPONE: : } "), methods (" { $link POSTPONE: M: } "), and vocabularies (" { $link POSTPONE: IN: } ")." +$nl +"All definitions share some common traits:" +{ $list + "There is a word to list all definitions of a given type" + "There is a parsing word for creating new definitions" + "There is an ordinary word which is the runtime equivalent of the parsing word, for introspection" + "Instances of the definition may be introspected and modified with the definition protocol" +} +"For every source file loaded into the system, a list of definitions is maintained. Pathname objects implement the definition protocol, acting over the definitions their source files contain. See " { $link "source-files" } " for details." { $subsection "definition-protocol" } { $subsection "definition-crossref" } { $subsection "definition-checking" } { $subsection "compilation-units" } +"A parsing word to remove definitions:" +{ $subsection POSTPONE: FORGET: } { $see-also "see" "parser" "source-files" "words" "generic" "help-impl" } ; ABOUT: "definitions" diff --git a/core/effects/effects-docs.factor b/core/effects/effects-docs.factor index b209dcf259..20709ca807 100644 --- a/core/effects/effects-docs.factor +++ b/core/effects/effects-docs.factor @@ -1,4 +1,4 @@ -USING: help.markup help.syntax math strings words kernel ; +USING: help.markup help.syntax math strings words kernel combinators ; IN: effects ARTICLE: "effect-declaration" "Stack effect declaration" @@ -29,14 +29,11 @@ $nl "The stack effect inferencer verifies stack effect comments to ensure the correct number of inputs and outputs is listed. Value names are ignored; only their number matters. An error is thrown if a word's declared stack effect does not match its inferred stack effect. See " { $link "inference" } "." ; 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." +"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. Stack effects are first-class, and words for working with them are found in the " { $vocab-link "effects" } " vocabulary." $nl -"Stack effects of words can be declared." +"Stack effects of words must be declared, and the " { $link "compiler" } " checks that these declarations are correct. Invalid declarations are reported as " { $link "compiler-errors" } ". The " { $link "inference" } " tool can be used to check stack effects interactively." { $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? } -"There is a literal syntax for stack objects. It is most often used with " { $link define-declared } "." +"There is a literal syntax for stack objects. It is most often used with " { $link define-declared } ", " { $link call-effect } " and " { $link execute-effect } "." { $subsection POSTPONE: (( } "Getting a word's declared stack effect:" { $subsection stack-effect } @@ -45,7 +42,9 @@ $nl "Comparing effects:" { $subsection effect-height } { $subsection effect<= } -{ $see-also "inference" } ; +"The class of stack effects:" +{ $subsection effect } +{ $subsection effect? } ; ABOUT: "effects" diff --git a/core/generic/generic-docs.factor b/core/generic/generic-docs.factor index 06a8fa87a3..7017ef8a08 100644 --- a/core/generic/generic-docs.factor +++ b/core/generic/generic-docs.factor @@ -45,8 +45,8 @@ $nl { $subsection make-generic } "Low-level method constructor:" { $subsection } -"A " { $emphasis "method specifier" } " refers to a method and implements the " { $link "definition-protocol" } ":" -{ $subsection method-spec } +"Methods may be pushed on the stack with a literal syntax:" +{ $subsection POSTPONE: M\ } { $see-also "see" } ; ARTICLE: "method-combination" "Custom method combination" @@ -98,8 +98,8 @@ $nl "Generic words must declare their stack effect in order to compile. See " { $link "effect-declaration" } "." { $subsection "method-order" } { $subsection "call-next-method" } -{ $subsection "generic-introspection" } { $subsection "method-combination" } +{ $subsection "generic-introspection" } "Generic words specialize behavior based on the class of an object; sometimes behavior needs to be specialized on the object's " { $emphasis "structure" } "; this is known as " { $emphasis "pattern matching" } " and is implemented in the " { $vocab-link "match" } " vocabulary." ; ABOUT: "generic" @@ -119,9 +119,10 @@ HELP: define-generic { $description "Defines a generic word. A method combination is an object which responds to the " { $link perform-combination } " generic word." } { $contract "The method combination quotation is called each time the generic word has to be updated (for example, when a method is added), and thus must be side-effect free." } ; -HELP: method-spec -{ $class-description "The class of method specifiers, which are two-element arrays consisting of a class word followed by a generic word." } -{ $examples { $code "{ fixnum + }" "{ editor draw-gadget* }" } } ; +HELP: M\ +{ $syntax "M\\ class generic" } +{ $class-description "Pushes a method on the stack." } +{ $examples { $code "M\\ fixnum + see" } { $code "USING: ui.gadgets ui.gadgets.editors ;" "M\\ editor draw-gadget* edit" } } ; HELP: method-body { $class-description "The class of method bodies, which are words with special word properties set." } ; diff --git a/core/generic/generic-tests.factor b/core/generic/generic-tests.factor index aadc44833f..151c2f52fa 100755 --- a/core/generic/generic-tests.factor +++ b/core/generic/generic-tests.factor @@ -105,9 +105,6 @@ M: shit big-generic-test "shit" ; [ float ] [ \ real \ float math-class-max ] unit-test [ fixnum ] [ \ fixnum \ null math-class-max ] unit-test -[ t ] [ { hashtable equal? } method-spec? ] unit-test -[ f ] [ { word = } method-spec? ] unit-test - ! Regression TUPLE: first-one ; TUPLE: second-one ; diff --git a/core/generic/math/math-docs.factor b/core/generic/math/math-docs.factor index 4323f91bc3..60fa745339 100644 --- a/core/generic/math/math-docs.factor +++ b/core/generic/math/math-docs.factor @@ -15,7 +15,7 @@ HELP: no-math-method HELP: math-method { $values { "word" generic } { "class1" class } { "class2" class } { "quot" quotation } } { $description "Generates a definition for " { $snippet "word" } " when the two inputs are instances of " { $snippet "class1" } " and " { $snippet "class2" } ", respectively." } -{ $examples { $example "USING: generic.math math prettyprint ;" "\\ + fixnum float math-method ." "[ { fixnum float } declare [ >float ] dip float=>+ ]" } } ; +{ $examples { $example "USING: generic.math math prettyprint ;" "\\ + fixnum float math-method ." "[ { fixnum float } declare [ >float ] dip M\\ float + ]" } } ; HELP: math-class { $class-description "The class of subtypes of " { $link number } " which are not " { $link null } "." } ; diff --git a/core/kernel/kernel-docs.factor b/core/kernel/kernel-docs.factor index c178573a0a..36d04f1437 100644 --- a/core/kernel/kernel-docs.factor +++ b/core/kernel/kernel-docs.factor @@ -841,260 +841,6 @@ $nl { $subsection roll } { $subsection -roll } ; -ARTICLE: "cleave-shuffle-equivalence" "Expressing shuffle words with cleave combinators" -"Cleave combinators are defined in terms of shuffle words, and mappings from certain shuffle idioms to cleave combinators are discussed in the documentation for " { $link bi } ", " { $link 2bi } ", " { $link 3bi } ", " { $link tri } ", " { $link 2tri } " and " { $link 3tri } "." -$nl -"Certain shuffle words can also be expressed in terms of the cleave combinators. Internalizing such identities can help with understanding and writing code using cleave combinators:" -{ $code - ": keep [ ] bi ;" - ": 2keep [ ] 2bi ;" - ": 3keep [ ] 3bi ;" - "" - ": dup [ ] [ ] bi ;" - ": 2dup [ ] [ ] 2bi ;" - ": 3dup [ ] [ ] 3bi ;" - "" - ": tuck [ nip ] [ ] 2bi ;" - ": swap [ nip ] [ drop ] 2bi ;" - "" - ": over [ ] [ drop ] 2bi ;" - ": pick [ ] [ 2drop ] 3bi ;" - ": 2over [ ] [ drop ] 3bi ;" -} ; - -ARTICLE: "cleave-combinators" "Cleave combinators" -"The cleave combinators apply multiple quotations to a single value." -$nl -"Two quotations:" -{ $subsection bi } -{ $subsection 2bi } -{ $subsection 3bi } -"Three quotations:" -{ $subsection tri } -{ $subsection 2tri } -{ $subsection 3tri } -"Technically, the cleave combinators are redundant because they can be simulated using shuffle words and other combinators, and in addition, they do not reduce token counts by much, if at all. However, they can make code more readable by expressing intention and exploiting any inherent symmetry. For example, a piece of code which performs three operations on the top of the stack can be written in one of two ways:" -{ $code - "! First alternative; uses keep" - "[ 1 + ] keep" - "[ 1 - ] keep" - "2 *" - "! Second alternative: uses tri" - "[ 1 + ]" - "[ 1 - ]" - "[ 2 * ] tri" -} -"The latter is more aesthetically pleasing than the former." -$nl -"A generalization of the above combinators to any number of quotations can be found in " { $link "combinators" } "." -{ $subsection "cleave-shuffle-equivalence" } ; - -ARTICLE: "spread-shuffle-equivalence" "Expressing shuffle words with spread combinators" -"Spread combinators are defined in terms of shuffle words, and mappings from certain shuffle idioms to spread combinators are discussed in the documentation for " { $link bi* } ", " { $link 2bi* } ", " { $link tri* } ", and " { $link 2tri* } "." -$nl -"Certain shuffle words can also be expressed in terms of the spread combinators. Internalizing such identities can help with understanding and writing code using spread combinators:" -{ $code - ": dip [ ] bi* ;" - ": 2dip [ ] [ ] tri* ;" - "" - ": slip [ call ] [ ] bi* ;" - ": 2slip [ call ] [ ] [ ] tri* ;" - "" - ": nip [ drop ] [ ] bi* ;" - ": 2nip [ drop ] [ drop ] [ ] tri* ;" - "" - ": rot" - " [ [ drop ] [ ] [ drop ] tri* ]" - " [ [ drop ] [ drop ] [ ] tri* ]" - " [ [ ] [ drop ] [ drop ] tri* ]" - " 3tri ;" - "" - ": -rot" - " [ [ drop ] [ drop ] [ ] tri* ]" - " [ [ ] [ drop ] [ drop ] tri* ]" - " [ [ drop ] [ ] [ drop ] tri* ]" - " 3tri ;" - "" - ": spin" - " [ [ drop ] [ drop ] [ ] tri* ]" - " [ [ drop ] [ ] [ drop ] tri* ]" - " [ [ ] [ drop ] [ drop ] tri* ]" - " 3tri ;" -} ; - -ARTICLE: "spread-combinators" "Spread combinators" -"The spread combinators apply multiple quotations to multiple values. The " { $snippet "*" } " suffix signifies spreading." -$nl -"Two quotations:" -{ $subsection bi* } -{ $subsection 2bi* } -"Three quotations:" -{ $subsection tri* } -{ $subsection 2tri* } -"Technically, the spread combinators are redundant because they can be simulated using shuffle words and other combinators, and in addition, they do not reduce token counts by much, if at all. However, they can make code more readable by expressing intention and exploiting any inherent symmetry. For example, a piece of code which performs three operations on three related values can be written in one of two ways:" -{ $code - "! First alternative; uses dip" - "[ [ 1 + ] dip 1 - ] dip 2 *" - "! Second alternative: uses tri*" - "[ 1 + ] [ 1 - ] [ 2 * ] tri*" -} -"A generalization of the above combinators to any number of quotations can be found in " { $link "combinators" } "." -{ $subsection "spread-shuffle-equivalence" } ; - -ARTICLE: "apply-combinators" "Apply combinators" -"The apply combinators apply a single quotation to multiple values. The " { $snippet "@" } " suffix signifies application." -$nl -"Two quotations:" -{ $subsection bi@ } -{ $subsection 2bi@ } -"Three quotations:" -{ $subsection tri@ } -{ $subsection 2tri@ } -"A pair of utility words built from " { $link bi@ } ":" -{ $subsection both? } -{ $subsection either? } ; - -ARTICLE: "slip-keep-combinators" "Retain stack combinators" -"Sometimes an additional storage area is needed to hold objects. The " { $emphasis "retain stack" } " is an auxilliary stack for this purpose. Objects can be moved between the data and retain stacks using a set of combinators." -$nl -"The dip combinators invoke the quotation at the top of the stack, hiding the values underneath:" -{ $subsection dip } -{ $subsection 2dip } -{ $subsection 3dip } -{ $subsection 4dip } -"The slip combinators invoke a quotation further down on the stack. They are most useful for implementing other combinators:" -{ $subsection slip } -{ $subsection 2slip } -{ $subsection 3slip } -"The keep combinators invoke a quotation which takes a number of values off the stack, and then they restore those values:" -{ $subsection keep } -{ $subsection 2keep } -{ $subsection 3keep } ; - -ARTICLE: "curried-dataflow" "Curried dataflow combinators" -"Curried cleave combinators:" -{ $subsection bi-curry } -{ $subsection tri-curry } -"Curried spread combinators:" -{ $subsection bi-curry* } -{ $subsection tri-curry* } -"Curried apply combinators:" -{ $subsection bi-curry@ } -{ $subsection tri-curry@ } -{ $see-also "dataflow-combinators" } ; - -ARTICLE: "compositional-examples" "Examples of compositional combinator usage" -"Consider printing the same message ten times:" -{ $code ": print-10 ( -- ) 10 [ \"Hello, world.\" print ] times ;" } -"if we wanted to abstract out the message into a parameter, we could keep it on the stack between iterations:" -{ $code ": print-10 ( message -- ) 10 [ dup print ] times drop ;" } -"However, keeping loop-invariant values on the stack doesn't always work out nicely. For example, a word to subtract a value from each element of a sequence:" -{ $code ": subtract-n ( seq n -- seq' ) swap [ over - ] map nip ;" } -"Three shuffle words are required to pass the value around. Instead, the loop-invariant value can be partially applied to a quotation using " { $link curry } ", yielding a new quotation that is passed to " { $link map } ":" -{ $example - "USING: kernel math prettyprint sequences ;" - ": subtract-n ( seq n -- seq' ) [ - ] curry map ;" - "{ 10 20 30 } 5 subtract-n ." - "{ 5 15 25 }" -} -"Now consider the word that is dual to the one above; instead of subtracting " { $snippet "n" } " from each stack element, it subtracts each element from " { $snippet "n" } "." -$nl -"One way to write this is with a pair of " { $link swap } "s:" -{ $code ": n-subtract ( n seq -- seq' ) swap [ swap - ] curry map ;" } -"Since this pattern comes up often, " { $link with } " encapsulates it:" -{ $example - "USING: kernel math prettyprint sequences ;" - ": n-subtract ( n seq -- seq' ) [ - ] with map ;" - "30 { 10 20 30 } n-subtract ." - "{ 20 10 0 }" -} -{ $see-also "fry.examples" } ; - -ARTICLE: "compositional-combinators" "Compositional combinators" -"Certain combinators transform quotations to produce a new quotation." -{ $subsection "compositional-examples" } -"Fundamental operations:" -{ $subsection curry } -{ $subsection compose } -"Derived operations:" -{ $subsection 2curry } -{ $subsection 3curry } -{ $subsection with } -{ $subsection prepose } -"These operations run in constant time, and in many cases are optimized out altogether by the " { $link "compiler" } ". " { $link "fry" } " are an abstraction built on top of these operations, and code that uses this abstraction is often clearer than direct calls to the below words." -$nl -"Curried dataflow combinators can be used to build more complex dataflow by combining cleave, spread and apply patterns in various ways." -{ $subsection "curried-dataflow" } -"Quotations also implement the sequence protocol, and can be manipulated with sequence words; see " { $link "quotations" } ". However, such runtime quotation manipulation will not be optimized by the optimizing compiler." ; - -ARTICLE: "implementing-combinators" "Implementing combinators" -"The following pair of words invoke words and quotations reflectively:" -{ $subsection call } -{ $subsection execute } -"These words are used to implement combinators. Note that combinator definitions must be followed by the " { $link POSTPONE: inline } " declaration in order to compile in the optimizing compiler; for example:" -{ $code - ": keep ( x quot -- x )" - " over [ call ] dip ; inline" -} -"Word inlining is documented in " { $link "declarations" } "." ; - -ARTICLE: "booleans" "Booleans" -"In Factor, any object that is not " { $link f } " has a true value, and " { $link f } " has a false value. The " { $link t } " object is the canonical true value." -{ $subsection f } -{ $subsection t } -"The " { $link f } " object is the unique instance of the " { $link f } " class; the two are distinct objects. The latter is also a parsing word which adds the " { $link f } " object to the parse tree at parse time. To refer to the class itself you must use " { $link POSTPONE: POSTPONE: } " or " { $link POSTPONE: \ } " to prevent the parsing word from executing." -$nl -"Here is the " { $link f } " object:" -{ $example "f ." "f" } -"Here is the " { $link f } " class:" -{ $example "\\ f ." "POSTPONE: f" } -"They are not equal:" -{ $example "f \\ f = ." "f" } -"Here is an array containing the " { $link f } " object:" -{ $example "{ f } ." "{ f }" } -"Here is an array containing the " { $link f } " class:" -{ $example "{ POSTPONE: f } ." "{ POSTPONE: f }" } -"The " { $link f } " object is an instance of the " { $link f } " class:" -{ $example "USE: classes" "f class ." "POSTPONE: f" } -"The " { $link f } " class is an instance of " { $link word } ":" -{ $example "USE: classes" "\\ f class ." "word" } -"On the other hand, " { $link t } " is just a word, and there is no class which it is a unique instance of." -{ $example "t \\ t eq? ." "t" } -"Many words which search collections confuse the case of no element being present with an element being found equal to " { $link f } ". If this distinction is imporant, there is usually an alternative word which can be used; for example, compare " { $link at } " with " { $link at* } "." ; - -ARTICLE: "conditionals-boolean-equivalence" "Expressing conditionals with boolean logic" -"Certain simple conditional forms can be expressed in a simpler manner using boolean logic." -$nl -"The following two lines are equivalent:" -{ $code "[ drop f ] unless" "swap and" } -"The following two lines are equivalent:" -{ $code "[ ] [ ] ?if" "swap or" } -"The following two lines are equivalent, where " { $snippet "L" } " is a literal:" -{ $code "[ L ] unless*" "L or" } ; - -ARTICLE: "conditionals" "Conditionals and logic" -"The basic conditionals:" -{ $subsection if } -{ $subsection when } -{ $subsection unless } -"Forms abstracting a common stack shuffle pattern:" -{ $subsection if* } -{ $subsection when* } -{ $subsection unless* } -"Another form abstracting a common stack shuffle pattern:" -{ $subsection ?if } -"Sometimes instead of branching, you just need to pick one of two values:" -{ $subsection ? } -"There are some logical operations on booleans:" -{ $subsection >boolean } -{ $subsection not } -{ $subsection and } -{ $subsection or } -{ $subsection xor } -{ $subsection "conditionals-boolean-equivalence" } -"See " { $link "combinators" } " for forms which abstract away common patterns involving multiple nested branches." -{ $see-also "booleans" "bitwise-arithmetic" both? either? } ; - ARTICLE: "equality" "Equality" "There are two distinct notions of “sameness” when it comes to objects." $nl @@ -1116,34 +862,3 @@ ARTICLE: "assertions" "Assertions" { $subsection assert } { $subsection assert= } ; -ARTICLE: "dataflow-combinators" "Data flow combinators" -"Data flow combinators pass values between quotations:" -{ $subsection "slip-keep-combinators" } -{ $subsection "cleave-combinators" } -{ $subsection "spread-combinators" } -{ $subsection "apply-combinators" } -{ $see-also "curried-dataflow" } ; - -ARTICLE: "dataflow" "Data and control flow" -{ $subsection "evaluator" } -{ $subsection "words" } -{ $subsection "effects" } -{ $subsection "booleans" } -{ $subsection "shuffle-words" } -"A central concept in Factor is that of a " { $emphasis "combinator" } ", which is a word taking code as input." -{ $subsection "dataflow-combinators" } -{ $subsection "conditionals" } -{ $subsection "looping-combinators" } -{ $subsection "compositional-combinators" } -{ $subsection "combinators" } -"More combinators are defined for working on data structures, such as " { $link "sequences-combinators" } " and " { $link "assocs-combinators" } "." -$nl -"Advanced topics:" -{ $subsection "assertions" } -{ $subsection "implementing-combinators" } -{ $subsection "macros" } -{ $subsection "errors" } -{ $subsection "continuations" } ; - -ABOUT: "dataflow" - diff --git a/core/math/math-docs.factor b/core/math/math-docs.factor index f79dcb5481..c28bf062c1 100644 --- a/core/math/math-docs.factor +++ b/core/math/math-docs.factor @@ -355,8 +355,9 @@ ARTICLE: "bitwise-arithmetic" "Bitwise arithmetic" { $subsection 2/ } { $subsection 2^ } { $subsection bit? } -"The " { $vocab-link "math.bitwise" } " vocabulary implements additional bitwise integer operations." -{ $see-also "conditionals" } ; +{ $subsection "math.bitwise" } +{ $subsection "math.bits" } +{ $see-also "booleans" } ; ARTICLE: "arithmetic" "Arithmetic" "Factor attempts to preserve natural mathematical semantics for numbers. Multiplying two large integers never results in overflow, and dividing two integers yields an exact ratio. Floating point numbers are also supported, along with complex numbers." diff --git a/core/math/order/order-docs.factor b/core/math/order/order-docs.factor index 1bdd1009e9..8b2200aa67 100644 --- a/core/math/order/order-docs.factor +++ b/core/math/order/order-docs.factor @@ -87,7 +87,14 @@ ARTICLE: "order-specifiers" "Ordering specifiers" { $subsection +lt+ } { $subsection +eq+ } { $subsection +gt+ } ; - + +ARTICLE: "math.order.example" "Linear order example" +"A tuple class which defines an ordering among instances by comparing the values of the " { $snippet "id" } " slot:" +{ $code + "TUPLE: sprite id name bitmap ;" + "M: sprite <=> [ id>> ] compare ;" +} ; + ARTICLE: "math.order" "Linear order protocol" "Some classes have an intrinsic order amongst instances:" { $subsection <=> } @@ -101,6 +108,8 @@ ARTICLE: "math.order" "Linear order protocol" { $subsection before? } { $subsection after=? } { $subsection before=? } +"Out of the above generic words, it suffices to implement " { $link <=> } " alone. The others may be provided as an optimization." +{ $subsection "math.order.example" } { $see-also "sequences-sorting" } ; ABOUT: "math.order" diff --git a/core/namespaces/namespaces-docs.factor b/core/namespaces/namespaces-docs.factor index ff0542a7b8..74d7c58963 100644 --- a/core/namespaces/namespaces-docs.factor +++ b/core/namespaces/namespaces-docs.factor @@ -32,7 +32,7 @@ ARTICLE: "namespaces.private" "Namespace implementation details" { $subsection >n } { $subsection ndrop } ; -ARTICLE: "namespaces" "Variables and namespaces" +ARTICLE: "namespaces" "Dynamic variables and namespaces" "The " { $vocab-link "namespaces" } " vocabulary implements simple dynamically-scoped variables." $nl "A variable is an entry in an assoc of bindings, where the assoc is implicit rather than passed on the stack. These assocs are termed " { $emphasis "namespaces" } ". Nesting of scopes is implemented with a search order on namespaces, defined by a " { $emphasis "namestack" } ". Since namespaces are just assoc, any object can be used as a variable, however by convention, variables are keyed by symbols (see " { $link "words.symbol" } ")." @@ -43,7 +43,6 @@ $nl "Various utility words abstract away common variable access patterns:" { $subsection "namespaces-change" } { $subsection "namespaces-combinators" } -{ $subsection "namespaces-global" } "Implementation details your code probably does not care about:" { $subsection "namespaces.private" } "An alternative to dynamic scope is lexical scope. Lexically-scoped values and closures are implemented in the " { $vocab-link "locals" } " vocabulary." ; diff --git a/core/parser/parser-docs.factor b/core/parser/parser-docs.factor index 547f7c0490..be4b345f4f 100644 --- a/core/parser/parser-docs.factor +++ b/core/parser/parser-docs.factor @@ -92,9 +92,7 @@ ARTICLE: "parser" "The parser" "This parser is a general facility for reading textual representations of objects and definitions. The parser is implemented in the " { $vocab-link "parser" } " and " { $vocab-link "syntax" } " vocabularies." $nl "This section concerns itself with usage and extension of the parser. Standard syntax is described in " { $link "syntax" } "." -{ $subsection "vocabulary-search" } { $subsection "parser-files" } -{ $subsection "top-level-forms" } "The parser can be extended." { $subsection "parsing-words" } { $subsection "parser-lexer" } diff --git a/core/quotations/quotations-docs.factor b/core/quotations/quotations-docs.factor index 2a03b7c74f..a72f4adf88 100644 --- a/core/quotations/quotations-docs.factor +++ b/core/quotations/quotations-docs.factor @@ -24,7 +24,7 @@ ARTICLE: "wrappers" "Wrappers" "Wrappers are used to push words on the data stack; they evaluate to the object being wrapped:" { $subsection wrapper } { $subsection literalize } -{ $see-also "dataflow" "combinators" } ; +{ $see-also "combinators" } ; ABOUT: "quotations" diff --git a/core/sequences/sequences-docs.factor b/core/sequences/sequences-docs.factor index e2badc2031..4103950005 100755 --- a/core/sequences/sequences-docs.factor +++ b/core/sequences/sequences-docs.factor @@ -1354,14 +1354,16 @@ ARTICLE: "virtual-sequences" "Virtual sequences" "Virtual sequences allow different ways of accessing a sequence without having to create a new sequence or a new data structure altogether. To do this, they translate the virtual index into a normal index into an underlying sequence using the " { $link "virtual-sequences-protocol" } "." { $subsection "virtual-sequences-protocol" } ; -ARTICLE: "sequences-integers" "Integer sequences and counted loops" +ARTICLE: "sequences-integers" "Counted loops" "Integers support the sequence protocol in a trivial fashion; a non-negative integer presents its non-negative predecessors as elements. For example, the integer 3, when viewed as a sequence, contains the elements 0, 1, and 2. This is very useful for performing counted loops." $nl "For example, the " { $link each } " combinator, given an integer, simply calls a quotation that number of times, pushing a counter on each iteration that ranges from 0 up to that integer:" { $example "3 [ . ] each" "0\n1\n2" } "A common idiom is to iterate over a sequence, while also maintaining a loop counter. This can be done using " { $link each-index } ", " { $link map-index } " and " { $link reduce-index } "." $nl -"Combinators that produce new sequences, such as " { $link map } ", will output an array if the input is an integer." ; +"Combinators that produce new sequences, such as " { $link map } ", will output an array if the input is an integer." +$nl +"More elaborate counted loops can be performed with " { $link "math.ranges" } "." ; ARTICLE: "sequences-access" "Accessing sequence elements" { $subsection ?nth } @@ -1593,7 +1595,6 @@ $nl "Sequences implement a protocol:" { $subsection "sequence-protocol" } { $subsection "sequences-f" } -{ $subsection "sequences-integers" } "Sequence utility words can operate on any object whose class implements the sequence protocol. Most implementations are backed by storage. Some implementations obtain their elements from an underlying sequence, or compute them on the fly. These are known as " { $link "virtual-sequences" } "." { $subsection "sequences-access" } { $subsection "sequences-combinators" } @@ -1612,6 +1613,10 @@ $nl { $subsection "binary-search" } { $subsection "sets" } { $subsection "sequences-trimming" } +{ $subsection "sequences.deep" } +"Using sequences for looping:" +{ $subsection "sequences-integers" } +{ $subsection "ranges" } "For inner loops:" { $subsection "sequences-unsafe" } ; diff --git a/core/slots/slots-docs.factor b/core/slots/slots-docs.factor index 840fe628e0..1e5f9bf1dd 100644 --- a/core/slots/slots-docs.factor +++ b/core/slots/slots-docs.factor @@ -83,7 +83,7 @@ $nl "A word can be used to check if a class has an initial value or not:" { $subsection initial-value } ; -ARTICLE: "slots" "Slots" +ARTICLE: "slots" "Low-level slot operations" "The " { $vocab-link "slots" } " vocabulary contains words for introspecting the slots of an object. A " { $emphasis "slot" } " is a component of an object which can store a value." $nl { $link "tuples" } " are composed entirely of slots, and instances of " { $link "builtin-classes" } " consist of slots together with intrinsic data." @@ -104,6 +104,9 @@ $nl { $subsection define-changer } { $subsection define-slot-methods } { $subsection define-accessors } +"Unsafe slot access:" +{ $subsection slot } +{ $subsection set-slot } { $see-also "accessors" "mirrors" } ; ABOUT: "slots" diff --git a/extra/peg-lexer/tags.txt b/extra/peg-lexer/tags.txt index 47619a17f8..44385cf3b7 100644 --- a/extra/peg-lexer/tags.txt +++ b/extra/peg-lexer/tags.txt @@ -1 +1,2 @@ -reflection \ No newline at end of file +extensions +reflection From 1071a3c5644534127ec33551501e29b6d5ede673 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 6 Apr 2009 03:03:46 -0500 Subject: [PATCH 13/20] Fix ui.tools.browser.history tests --- .../tools/browser/history/history-tests.factor | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/basis/ui/tools/browser/history/history-tests.factor b/basis/ui/tools/browser/history/history-tests.factor index 20b16f450a..454e4700a0 100644 --- a/basis/ui/tools/browser/history/history-tests.factor +++ b/basis/ui/tools/browser/history/history-tests.factor @@ -1,7 +1,13 @@ -USING: namespaces ui.tools.browser.history sequences tools.test ; +USING: namespaces ui.tools.browser.history sequences tools.test +accessors kernel ; IN: ui.tools.browser.history.tests -f "history" set +TUPLE: dummy obj ; + +M: dummy history-value obj>> ; +M: dummy set-history-value (>>obj) ; + +dummy new "history" set "history" get add-history @@ -9,27 +15,27 @@ f "history" set [ t ] [ "history" get forward>> empty? ] unit-test "history" get add-history -"history" get 3 >>value drop +3 "history" get owner>> set-history-value [ t ] [ "history" get back>> empty? ] unit-test [ t ] [ "history" get forward>> empty? ] unit-test "history" get add-history -"history" get 4 >>value drop +4 "history" get owner>> set-history-value [ f ] [ "history" get back>> empty? ] unit-test [ t ] [ "history" get forward>> empty? ] unit-test "history" get go-back -[ 3 ] [ "history" get value>> ] unit-test +[ 3 ] [ "history" get owner>> history-value ] unit-test [ t ] [ "history" get back>> empty? ] unit-test [ f ] [ "history" get forward>> empty? ] unit-test "history" get go-forward -[ 4 ] [ "history" get value>> ] unit-test +[ 4 ] [ "history" get owner>> history-value ] unit-test [ f ] [ "history" get back>> empty? ] unit-test [ t ] [ "history" get forward>> empty? ] unit-test From 3af8643c309ef5ea0b1ad067b1378f02c6a18048 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 6 Apr 2009 03:03:58 -0500 Subject: [PATCH 14/20] More tags --- extra/descriptive/tags.txt | 1 + extra/multi-methods/tags.txt | 1 + 2 files changed, 2 insertions(+) create mode 100644 extra/descriptive/tags.txt create mode 100644 extra/multi-methods/tags.txt diff --git a/extra/descriptive/tags.txt b/extra/descriptive/tags.txt new file mode 100644 index 0000000000..f4274299b1 --- /dev/null +++ b/extra/descriptive/tags.txt @@ -0,0 +1 @@ +extensions diff --git a/extra/multi-methods/tags.txt b/extra/multi-methods/tags.txt new file mode 100644 index 0000000000..f4274299b1 --- /dev/null +++ b/extra/multi-methods/tags.txt @@ -0,0 +1 @@ +extensions From 0f04061079a8b6fbc157aa873a982d2c9a635693 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 6 Apr 2009 03:30:23 -0500 Subject: [PATCH 15/20] Fixing some unit test failures --- basis/prettyprint/prettyprint-tests.factor | 8 ++------ core/words/constant/constant-tests.factor | 8 +++++++- core/words/constant/constant.factor | 11 +++++++---- core/words/symbol/symbol.factor | 7 +++---- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/basis/prettyprint/prettyprint-tests.factor b/basis/prettyprint/prettyprint-tests.factor index 3350ae6c7b..799d500c18 100644 --- a/basis/prettyprint/prettyprint-tests.factor +++ b/basis/prettyprint/prettyprint-tests.factor @@ -278,11 +278,7 @@ GENERIC: generic-see-test-with-f ( obj -- obj ) M: f generic-see-test-with-f ; [ "USING: prettyprint.tests ;\nM: f generic-see-test-with-f ;\n" ] [ - [ { POSTPONE: f generic-see-test-with-f } see ] with-string-writer -] unit-test - -[ "USING: prettyprint.tests ;\nM: f generic-see-test-with-f ;\n" ] [ - [ \ f \ generic-see-test-with-f method see ] with-string-writer + [ M\ f generic-see-test-with-f see ] with-string-writer ] unit-test PREDICATE: predicate-see-test < integer even? ; @@ -309,5 +305,5 @@ GENERIC: ended-up-ballin' ( a -- b ) M: started-out-hustlin' ended-up-ballin' ; inline [ "USING: prettyprint.tests ;\nM: started-out-hustlin' ended-up-ballin' ; inline\n" ] [ - [ { started-out-hustlin' ended-up-ballin' } see ] with-string-writer + [ M\ started-out-hustlin' ended-up-ballin' see ] with-string-writer ] unit-test diff --git a/core/words/constant/constant-tests.factor b/core/words/constant/constant-tests.factor index 2755039af6..721846b2d1 100644 --- a/core/words/constant/constant-tests.factor +++ b/core/words/constant/constant-tests.factor @@ -1,10 +1,12 @@ IN: words.constant.tests -USING: tools.test math ; +USING: tools.test math words.constant ; CONSTANT: a + [ + ] [ a ] unit-test +[ t ] [ \ a constant? ] unit-test + CONSTANT: b \ + [ \ + ] [ b ] unit-test @@ -12,3 +14,7 @@ CONSTANT: b \ + CONSTANT: c { 1 2 3 } [ { 1 2 3 } ] [ c ] unit-test + +SYMBOL: foo + +[ f ] [ \ foo constant? ] unit-test \ No newline at end of file diff --git a/core/words/constant/constant.factor b/core/words/constant/constant.factor index 00302df98a..b518760bf9 100644 --- a/core/words/constant/constant.factor +++ b/core/words/constant/constant.factor @@ -3,12 +3,15 @@ USING: accessors kernel sequences words definitions quotations ; IN: words.constant -PREDICATE: constant < word ( obj -- ? ) - def>> dup length 1 = [ first word? not ] [ drop f ] if ; +PREDICATE: constant < word "constant" word-prop >boolean ; : define-constant ( word value -- ) - [ ] curry (( -- value )) define-inline ; + [ "constant" set-word-prop ] + [ [ ] curry (( -- value )) define-inline ] 2bi ; + +M: constant reset-word + [ call-next-method ] [ f "constant" set-word-prop ] bi ; M: constant definer drop \ CONSTANT: f ; -M: constant definition def>> first literalize 1quotation ; \ No newline at end of file +M: constant definition "constant" word-prop literalize 1quotation ; \ No newline at end of file diff --git a/core/words/symbol/symbol.factor b/core/words/symbol/symbol.factor index a107808eec..34ec6b9174 100644 --- a/core/words/symbol/symbol.factor +++ b/core/words/symbol/symbol.factor @@ -1,10 +1,9 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel sequences accessors definitions -words words.constant ; +USING: kernel sequences accessors definitions words ; IN: words.symbol -PREDICATE: symbol < constant ( obj -- ? ) +PREDICATE: symbol < word ( obj -- ? ) [ def>> ] [ [ ] curry ] bi sequence= ; M: symbol definer drop \ SYMBOL: f ; @@ -12,4 +11,4 @@ M: symbol definer drop \ SYMBOL: f ; M: symbol definition drop f ; : define-symbol ( word -- ) - dup define-constant ; + dup [ ] curry (( -- value )) define-inline ; From fb246e2c85497940576a8b08565e37acce8a177e Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 6 Apr 2009 04:15:58 -0500 Subject: [PATCH 16/20] Documentation fixes --- core/io/encodings/encodings-docs.factor | 4 ++-- core/sequences/sequences-docs.factor | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/io/encodings/encodings-docs.factor b/core/io/encodings/encodings-docs.factor index 204441c19a..d0f968a791 100644 --- a/core/io/encodings/encodings-docs.factor +++ b/core/io/encodings/encodings-docs.factor @@ -80,12 +80,12 @@ ARTICLE: "encodings-descriptors" "Encoding descriptors" "An encoding descriptor is something which can be used with binary input or output streams to encode or decode bytes stored in a certain representation. It must conform to the " { $link "encodings-protocol" } ". Encodings which you can use are defined in the following vocabularies:" { $subsection "io.encodings.binary" } { $subsection "io.encodings.utf8" } -{ $subsection "io.encodings.utf16" } +{ $vocab-subsection "UTF-16 encoding" "io.encodings.utf16" } { $vocab-subsection "UTF-32 encoding" "io.encodings.utf32" } { $vocab-subsection "Strict encodings" "io.encodings.strict" } "Legacy encodings:" { $vocab-subsection "8-bit encodings" "io.encodings.8-bit" } -{ $vocab-subsection "ASCII" "io.encodings.ascii" } +{ $vocab-subsection "ASCII encoding" "io.encodings.ascii" } { $see-also "encodings-introduction" } ; ARTICLE: "encodings-protocol" "Encoding protocol" diff --git a/core/sequences/sequences-docs.factor b/core/sequences/sequences-docs.factor index 4103950005..556e41249e 100755 --- a/core/sequences/sequences-docs.factor +++ b/core/sequences/sequences-docs.factor @@ -1616,7 +1616,7 @@ $nl { $subsection "sequences.deep" } "Using sequences for looping:" { $subsection "sequences-integers" } -{ $subsection "ranges" } +{ $subsection "math.ranges" } "For inner loops:" { $subsection "sequences-unsafe" } ; From 7bf0a46d3d02efa1aaa3dff0c5117f31d9134ec2 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 6 Apr 2009 04:16:39 -0500 Subject: [PATCH 17/20] Updating tests for method-spec removal --- core/classes/classes.factor | 3 +-- core/classes/tuple/tuple-tests.factor | 2 +- core/generic/generic.factor | 3 +++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/classes/classes.factor b/core/classes/classes.factor index eded33beed..ab8ba398cd 100644 --- a/core/classes/classes.factor +++ b/core/classes/classes.factor @@ -174,8 +174,7 @@ GENERIC: update-methods ( class seq -- ) [ forget ] [ drop ] if ] [ 2drop ] if ; -: forget-methods ( class -- ) - [ implementors ] [ [ swap 2array ] curry ] bi map forget-all ; +GENERIC: forget-methods ( class -- ) GENERIC: class-forgotten ( use class -- ) diff --git a/core/classes/tuple/tuple-tests.factor b/core/classes/tuple/tuple-tests.factor index fa2df4e312..6de1810a51 100644 --- a/core/classes/tuple/tuple-tests.factor +++ b/core/classes/tuple/tuple-tests.factor @@ -133,7 +133,7 @@ M: integer forget-robustness-generic ; [ [ ] [ \ forget-robustness-generic forget ] unit-test [ ] [ \ forget-robustness forget ] unit-test - [ ] [ { forget-robustness forget-robustness-generic } forget ] unit-test + [ ] [ M\ forget-robustness forget-robustness-generic forget ] unit-test ] with-compilation-unit ! rapido found this one diff --git a/core/generic/generic.factor b/core/generic/generic.factor index ab0685f1d6..65a802dc2d 100644 --- a/core/generic/generic.factor +++ b/core/generic/generic.factor @@ -188,5 +188,8 @@ M: generic subwords M: generic forget* [ subwords forget-all ] [ call-next-method ] bi ; +M: class forget-methods + [ implementors ] [ [ swap method ] curry ] bi map forget-all ; + : xref-generics ( -- ) all-words [ subwords [ xref ] each ] each ; From 890553b776009278dea4884cb5945f7b3ab56210 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 6 Apr 2009 05:22:28 -0500 Subject: [PATCH 18/20] Fixing tests for method-sec removal --- basis/locals/locals-tests.factor | 2 +- basis/models/arrow/smart/smart-docs.factor | 21 +++++++++++++++++++ .../annotations/annotations-tests.factor | 2 +- basis/tools/deploy/test/14/14.factor | 17 +++++++++++++++ basis/tools/deploy/test/14/authors.txt | 1 + basis/tools/deploy/test/14/deploy.factor | 15 +++++++++++++ basis/ui/traverse/traverse-docs.factor | 0 basis/ui/traverse/traverse-tests.factor | 2 +- core/classes/tuple/tuple-tests.factor | 2 +- core/definitions/definitions-tests.factor | 11 ++++------ core/generic/generic-tests.factor | 4 ++-- 11 files changed, 64 insertions(+), 13 deletions(-) create mode 100644 basis/models/arrow/smart/smart-docs.factor create mode 100644 basis/tools/deploy/test/14/14.factor create mode 100644 basis/tools/deploy/test/14/authors.txt create mode 100644 basis/tools/deploy/test/14/deploy.factor create mode 100644 basis/ui/traverse/traverse-docs.factor diff --git a/basis/locals/locals-tests.factor b/basis/locals/locals-tests.factor index 8e61e39faf..5e61c1ddfd 100644 --- a/basis/locals/locals-tests.factor +++ b/basis/locals/locals-tests.factor @@ -455,7 +455,7 @@ GENERIC: lambda-method-forget-test ( a -- b ) M:: integer lambda-method-forget-test ( a -- b ) ; -[ ] [ [ { integer lambda-method-forget-test } forget ] with-compilation-unit ] unit-test +[ ] [ [ M\ integer lambda-method-forget-test forget ] with-compilation-unit ] unit-test [ 10 ] [ 10 [| A | { [ A ] } ] call first call ] unit-test diff --git a/basis/models/arrow/smart/smart-docs.factor b/basis/models/arrow/smart/smart-docs.factor new file mode 100644 index 0000000000..45faf52b97 --- /dev/null +++ b/basis/models/arrow/smart/smart-docs.factor @@ -0,0 +1,21 @@ +IN: models.arrow.smart +USING: help.syntax help.markup models.product ; + +HELP: +{ $values { "quot" { $quotation "( ... -- output )" } } } +{ $description "A macro that expands into a form with the stack effect of the quotation. The form constructs a model which applies the quotation to values from an underlying " { $link product } " model having as many components as the quotation has inputs." } +{ $examples + "A model which adds the values of two existing models:" + { $example + "USING: models models.arrows.smart accessors math prettyprint ;" + "1 2 [ + ] " + "[ activate-model ] [ value>> ] bi ." + "3" + } +} ; + +ARTICLE: "models.arrows.smart" "Smart arrow models" +"The " { $vocab-link "models.arrows.smart" } " vocabulary generalizes arrows to arbitrary input arity. They're called “smart” because they resemble " { $link "combinators.smart" } "." +{ $subsection } ; + +ABOUT: "models.arrows.smart" \ No newline at end of file diff --git a/basis/tools/annotations/annotations-tests.factor b/basis/tools/annotations/annotations-tests.factor index f47852aca7..9fa9d1e2aa 100644 --- a/basis/tools/annotations/annotations-tests.factor +++ b/basis/tools/annotations/annotations-tests.factor @@ -43,6 +43,6 @@ GENERIC: blah-generic ( a -- b ) M: string blah-generic ; -{ string blah-generic } watch +[ ] [ M\ string blah-generic watch ] unit-test [ "hi" ] [ "hi" blah-generic ] unit-test diff --git a/basis/tools/deploy/test/14/14.factor b/basis/tools/deploy/test/14/14.factor new file mode 100644 index 0000000000..f21afc13d6 --- /dev/null +++ b/basis/tools/deploy/test/14/14.factor @@ -0,0 +1,17 @@ +! Copyright (C) 2009 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: alien threads ; +IN: tools.deploy.test.14 + +: (callback-yield-test) ( -- ) + "void" { } "cdecl" [ yield ] alien-callback + "void" { } "cdecl" alien-indirect ; + +: callback-yield-test ( -- ) + + "void" { } "cdecl" [ + (callback-yield-test) + ] alien-callback + "void" { } "cdecl" alien-indirect ; + +MAIN: callback-yield-test \ No newline at end of file diff --git a/basis/tools/deploy/test/14/authors.txt b/basis/tools/deploy/test/14/authors.txt new file mode 100644 index 0000000000..d4f5d6b3ae --- /dev/null +++ b/basis/tools/deploy/test/14/authors.txt @@ -0,0 +1 @@ +Slava Pestov \ No newline at end of file diff --git a/basis/tools/deploy/test/14/deploy.factor b/basis/tools/deploy/test/14/deploy.factor new file mode 100644 index 0000000000..0fe268822c --- /dev/null +++ b/basis/tools/deploy/test/14/deploy.factor @@ -0,0 +1,15 @@ +USING: tools.deploy.config ; +H{ + { deploy-name "tools.deploy.test.14" } + { deploy-threads? t } + { deploy-math? f } + { deploy-word-props? f } + { deploy-ui? f } + { deploy-io 1 } + { deploy-compiler? t } + { deploy-reflection 1 } + { "stop-after-last-window?" t } + { deploy-unicode? f } + { deploy-word-defs? f } + { deploy-c-types? f } +} diff --git a/basis/ui/traverse/traverse-docs.factor b/basis/ui/traverse/traverse-docs.factor new file mode 100644 index 0000000000..e69de29bb2 diff --git a/basis/ui/traverse/traverse-tests.factor b/basis/ui/traverse/traverse-tests.factor index e18637a652..4d2072db1c 100644 --- a/basis/ui/traverse/traverse-tests.factor +++ b/basis/ui/traverse/traverse-tests.factor @@ -62,4 +62,4 @@ M: object (flatten-tree) , ; { 0 1 } { 2 0 1 } { { "a" "b" "c" "d" } { "e" "f" "g" } { { "h" "i" } "j" } } gadgets-in-range ] unit-test -[ { array children>> } forget ] with-compilation-unit +[ M\ array children>> forget ] with-compilation-unit diff --git a/core/classes/tuple/tuple-tests.factor b/core/classes/tuple/tuple-tests.factor index 6de1810a51..75d733b213 100644 --- a/core/classes/tuple/tuple-tests.factor +++ b/core/classes/tuple/tuple-tests.factor @@ -559,7 +559,7 @@ DEFER: subclass-reset-test-3 GENERIC: break-me ( obj -- ) -[ ] [ [ { integer break-me } forget ] with-compilation-unit ] unit-test +[ ] [ [ M\ integer break-me forget ] with-compilation-unit ] unit-test [ ] [ "IN: classes.tuple.tests TUPLE: subclass-reset-test ;" "subclass-reset-test" parse-stream drop ] unit-test [ ] [ "IN: classes.tuple.tests TUPLE: subclass-reset-test-1 < subclass-reset-test ;" eval ] unit-test diff --git a/core/definitions/definitions-tests.factor b/core/definitions/definitions-tests.factor index b2d265a2e3..558b259103 100644 --- a/core/definitions/definitions-tests.factor +++ b/core/definitions/definitions-tests.factor @@ -20,14 +20,11 @@ TUPLE: some-class ; M: some-class some-generic ; -TUPLE: another-class some-generic ; - [ ] [ [ - { - some-generic - some-class - { another-class some-generic } - } forget-all + \ some-generic + \ some-class + 2array + forget-all ] with-compilation-unit ] unit-test diff --git a/core/generic/generic-tests.factor b/core/generic/generic-tests.factor index 151c2f52fa..f28332353e 100755 --- a/core/generic/generic-tests.factor +++ b/core/generic/generic-tests.factor @@ -161,7 +161,7 @@ M: sequence generic-forget-test-2 = ; ] unit-test [ ] [ - [ { sequence generic-forget-test-2 } forget ] with-compilation-unit + [ M\ sequence generic-forget-test-2 forget ] with-compilation-unit ] unit-test [ f ] [ @@ -231,7 +231,7 @@ M: number c-n-m-cache ; [ 3 ] [ 2 c-n-m-cache ] unit-test -[ ] [ [ { integer c-n-m-cache } forget ] with-compilation-unit ] unit-test +[ ] [ [ M\ integer c-n-m-cache forget ] with-compilation-unit ] unit-test [ 2 ] [ 2 c-n-m-cache ] unit-test From cb9e4a40692fdd55c6e9616be903510c3276d3a5 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 6 Apr 2009 05:22:43 -0500 Subject: [PATCH 19/20] Oops --- basis/tools/deploy/test/14/14.factor | 17 ----------------- basis/tools/deploy/test/14/authors.txt | 1 - basis/tools/deploy/test/14/deploy.factor | 15 --------------- 3 files changed, 33 deletions(-) delete mode 100644 basis/tools/deploy/test/14/14.factor delete mode 100644 basis/tools/deploy/test/14/authors.txt delete mode 100644 basis/tools/deploy/test/14/deploy.factor diff --git a/basis/tools/deploy/test/14/14.factor b/basis/tools/deploy/test/14/14.factor deleted file mode 100644 index f21afc13d6..0000000000 --- a/basis/tools/deploy/test/14/14.factor +++ /dev/null @@ -1,17 +0,0 @@ -! Copyright (C) 2009 Slava Pestov. -! See http://factorcode.org/license.txt for BSD license. -USING: alien threads ; -IN: tools.deploy.test.14 - -: (callback-yield-test) ( -- ) - "void" { } "cdecl" [ yield ] alien-callback - "void" { } "cdecl" alien-indirect ; - -: callback-yield-test ( -- ) - - "void" { } "cdecl" [ - (callback-yield-test) - ] alien-callback - "void" { } "cdecl" alien-indirect ; - -MAIN: callback-yield-test \ No newline at end of file diff --git a/basis/tools/deploy/test/14/authors.txt b/basis/tools/deploy/test/14/authors.txt deleted file mode 100644 index d4f5d6b3ae..0000000000 --- a/basis/tools/deploy/test/14/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Slava Pestov \ No newline at end of file diff --git a/basis/tools/deploy/test/14/deploy.factor b/basis/tools/deploy/test/14/deploy.factor deleted file mode 100644 index 0fe268822c..0000000000 --- a/basis/tools/deploy/test/14/deploy.factor +++ /dev/null @@ -1,15 +0,0 @@ -USING: tools.deploy.config ; -H{ - { deploy-name "tools.deploy.test.14" } - { deploy-threads? t } - { deploy-math? f } - { deploy-word-props? f } - { deploy-ui? f } - { deploy-io 1 } - { deploy-compiler? t } - { deploy-reflection 1 } - { "stop-after-last-window?" t } - { deploy-unicode? f } - { deploy-word-defs? f } - { deploy-c-types? f } -} From dd43df655f6707b693b5cccc85e3c8d5ad951cb5 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Mon, 6 Apr 2009 10:45:39 -0500 Subject: [PATCH 20/20] fix unit test for new method syntax --- basis/tools/disassembler/disassembler-tests.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/tools/disassembler/disassembler-tests.factor b/basis/tools/disassembler/disassembler-tests.factor index 96f5a04378..49cfb054a1 100644 --- a/basis/tools/disassembler/disassembler-tests.factor +++ b/basis/tools/disassembler/disassembler-tests.factor @@ -3,4 +3,4 @@ USING: math classes.tuple prettyprint.custom tools.disassembler tools.test strings ; [ ] [ \ + disassemble ] unit-test -[ ] [ { string pprint* } disassemble ] unit-test +[ ] [ M\ string pprint* disassemble ] unit-test