diff --git a/basis/combinators/short-circuit/short-circuit-docs.factor b/basis/combinators/short-circuit/short-circuit-docs.factor index 54fc3aac43..6cd18201fe 100644 --- a/basis/combinators/short-circuit/short-circuit-docs.factor +++ b/basis/combinators/short-circuit/short-circuit-docs.factor @@ -52,17 +52,17 @@ HELP: 3|| { "quot" quotation } } { $description "Returns true if any quotation in the sequence returns true. Each quotation takes the same three elements from the datastack and must return a boolean." } ; -HELP: n&&-rewrite +HELP: n&& { $values { "quots" "a sequence of quotations" } { "N" integer } { "quot" quotation } } -{ $description "A macro that reqrites the code to pass " { $snippet "N" } " parameters from the stack to each AND quotation." } ; +{ $description "A macro that rewrites the code to pass " { $snippet "n" } " parameters from the stack to each AND quotation." } ; -HELP: n||-rewrite +HELP: n|| { $values - { "quots" "a sequence of quotations" } { "N" integer } + { "quots" "a sequence of quotations" } { "n" integer } { "quot" quotation } } -{ $description "A macro that reqrites the code to pass " { $snippet "N" } " parameters from the stack to each OR quotation." } ; +{ $description "A macro that rewrites the code to pass " { $snippet "n" } " parameters from the stack to each OR quotation." } ; ARTICLE: "combinators.short-circuit" "Short-circuit combinators" "The " { $vocab-link "combinators.short-circuit" } " vocabulary stops a computation early once a condition is met." $nl @@ -77,8 +77,8 @@ ARTICLE: "combinators.short-circuit" "Short-circuit combinators" { $subsection 2|| } { $subsection 3|| } "Generalized combinators:" -{ $subsection n&&-rewrite } -{ $subsection n||-rewrite } +{ $subsection n&& } +{ $subsection n|| } ; ABOUT: "combinators.short-circuit" diff --git a/basis/combinators/short-circuit/short-circuit.factor b/basis/combinators/short-circuit/short-circuit.factor index 7b6c1d126d..2b4e522789 100644 --- a/basis/combinators/short-circuit/short-circuit.factor +++ b/basis/combinators/short-circuit/short-circuit.factor @@ -1,35 +1,26 @@ - USING: kernel combinators quotations arrays sequences assocs - locals generalizations macros fry ; - +locals generalizations macros fry ; IN: combinators.short-circuit -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +MACRO:: n&& ( quots n -- quot ) + [ f ] + quots [| q | { [ drop n ndup q call dup not ] [ drop n ndrop f ] } ] map + [ n nnip ] suffix 1array + [ cond ] 3append ; -:: n&&-rewrite ( quots N -- quot ) - quots - [ '[ drop N ndup @ dup not ] [ drop N ndrop f ] 2array ] - map - [ t ] [ N nnip ] 2array suffix - '[ f _ cond ] ; +MACRO: 0&& ( quots -- quot ) '[ _ 0 n&& ] ; +MACRO: 1&& ( quots -- quot ) '[ _ 1 n&& ] ; +MACRO: 2&& ( quots -- quot ) '[ _ 2 n&& ] ; +MACRO: 3&& ( quots -- quot ) '[ _ 3 n&& ] ; -MACRO: 0&& ( quots -- quot ) 0 n&&-rewrite ; -MACRO: 1&& ( quots -- quot ) 1 n&&-rewrite ; -MACRO: 2&& ( quots -- quot ) 2 n&&-rewrite ; -MACRO: 3&& ( quots -- quot ) 3 n&&-rewrite ; +MACRO:: n|| ( quots n -- quot ) + [ f ] + quots + [| q | { [ drop n ndup q call dup ] [ n nnip ] } ] map + { [ drop n ndrop t ] [ f ] } suffix 1array + [ cond ] 3append ; -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -:: n||-rewrite ( quots N -- quot ) - quots - [ '[ drop N ndup @ dup ] [ N nnip ] 2array ] - map - [ drop N ndrop t ] [ f ] 2array suffix - '[ f _ cond ] ; - -MACRO: 0|| ( quots -- quot ) 0 n||-rewrite ; -MACRO: 1|| ( quots -- quot ) 1 n||-rewrite ; -MACRO: 2|| ( quots -- quot ) 2 n||-rewrite ; -MACRO: 3|| ( quots -- quot ) 3 n||-rewrite ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +MACRO: 0|| ( quots -- quot ) '[ _ 0 n|| ] ; +MACRO: 1|| ( quots -- quot ) '[ _ 1 n|| ] ; +MACRO: 2|| ( quots -- quot ) '[ _ 2 n|| ] ; +MACRO: 3|| ( quots -- quot ) '[ _ 3 n|| ] ; diff --git a/basis/combinators/short-circuit/smart/smart.factor b/basis/combinators/short-circuit/smart/smart.factor index ca659cacbe..b80e7294d1 100644 --- a/basis/combinators/short-circuit/smart/smart.factor +++ b/basis/combinators/short-circuit/smart/smart.factor @@ -1,7 +1,5 @@ - USING: kernel sequences math stack-checker effects accessors macros - combinators.short-circuit ; - +fry combinators.short-circuit ; IN: combinators.short-circuit.smart -MACRO: && ( quots -- quot ) dup arity n&&-rewrite ; +MACRO: && ( quots -- quot ) dup arity '[ _ _ n&& ] ; -MACRO: || ( quots -- quot ) dup arity n||-rewrite ; +MACRO: || ( quots -- quot ) dup arity '[ _ _ n|| ] ; diff --git a/basis/compiler/tree/propagation/info/info.factor b/basis/compiler/tree/propagation/info/info.factor index e89a9c6211..771d3800df 100644 --- a/basis/compiler/tree/propagation/info/info.factor +++ b/basis/compiler/tree/propagation/info/info.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: assocs classes classes.algebra classes.tuple classes.tuple.private kernel accessors math math.intervals -namespaces sequences words combinators combinators.short-circuit +namespaces sequences words combinators arrays compiler.tree.propagation.copy ; IN: compiler.tree.propagation.info @@ -253,12 +253,13 @@ DEFER: (value-info-union) { [ over not ] [ 2drop f ] } [ { - [ [ class>> ] bi@ class<= ] - [ [ interval>> ] bi@ interval-subset? ] - [ literals<= ] - [ [ length>> ] bi@ value-info<= ] - [ [ slots>> ] bi@ [ value-info<= ] 2all? ] - } 2&& + { [ 2dup [ class>> ] bi@ class<= not ] [ f ] } + { [ 2dup [ interval>> ] bi@ interval-subset? not ] [ f ] } + { [ 2dup literals<= not ] [ f ] } + { [ 2dup [ length>> ] bi@ value-info<= not ] [ f ] } + { [ 2dup [ slots>> ] bi@ [ value-info<= ] 2all? not ] [ f ] } + [ t ] + } cond 2nip ] } cond ; diff --git a/basis/cpu/ppc/bootstrap.factor b/basis/cpu/ppc/bootstrap.factor index efe55f9a22..014d2b31a0 100644 --- a/basis/cpu/ppc/bootstrap.factor +++ b/basis/cpu/ppc/bootstrap.factor @@ -351,7 +351,7 @@ big-endian on 7 6 4 SUBF 5 ds-reg -4 STW 7 ds-reg 0 STW -] f f f \ fixnum-/mod-fast define-sub-primitive +] f f f \ fixnum/mod-fast define-sub-primitive [ 3 ds-reg 0 LWZ diff --git a/basis/editors/notepad2/authors.txt b/basis/editors/notepad2/authors.txt new file mode 100644 index 0000000000..7852139357 --- /dev/null +++ b/basis/editors/notepad2/authors.txt @@ -0,0 +1 @@ +Marc Fauconneau diff --git a/basis/editors/notepad2/notepad2.factor b/basis/editors/notepad2/notepad2.factor new file mode 100644 index 0000000000..4d333e45dd --- /dev/null +++ b/basis/editors/notepad2/notepad2.factor @@ -0,0 +1,16 @@ +USING: editors io.files io.launcher kernel math.parser +namespaces sequences windows.shell32 make ; +IN: editors.notepad2 + +: notepad2-path ( -- str ) + \ notepad2-path get-global [ + program-files "C:\\Windows\\system32\\notepad.exe" append-path + ] unless* ; + +: notepad2 ( file line -- ) + [ + notepad2-path , + "/g" , number>string , , + ] { } make run-detached drop ; + +[ notepad2 ] edit-hook set-global \ No newline at end of file diff --git a/basis/editors/notepad2/summary.txt b/basis/editors/notepad2/summary.txt new file mode 100644 index 0000000000..ab4a8ce377 --- /dev/null +++ b/basis/editors/notepad2/summary.txt @@ -0,0 +1 @@ +Notepad2 editor integration diff --git a/basis/editors/notepad2/tags.txt b/basis/editors/notepad2/tags.txt new file mode 100644 index 0000000000..6bf68304bb --- /dev/null +++ b/basis/editors/notepad2/tags.txt @@ -0,0 +1 @@ +unportable diff --git a/basis/fry/fry-docs.factor b/basis/fry/fry-docs.factor index 8f402f2e8c..b5d1b8d8d2 100644 --- a/basis/fry/fry-docs.factor +++ b/basis/fry/fry-docs.factor @@ -19,6 +19,9 @@ HELP: '[ { $description "Literal fried quotation. Expands into code which takes values from the stack and substitutes them in place of the fry specifiers " { $link _ } " and " { $link @ } "." } { $examples "See " { $link "fry.examples" } "." } ; +HELP: >r/r>-in-fry-error +{ $error-description "Thrown by " { $link POSTPONE: '[ } " if the fried quotation contains calls to " { $link >r } " or " { $link r> } ". Explicit retain stack manipulation of this form does not work with fry; use " { $link dip } " instead." } ; + ARTICLE: "fry.examples" "Examples of fried quotations" "The easiest way to understand fried quotations is to look at some examples." $nl @@ -73,7 +76,10 @@ ARTICLE: "fry.philosophy" "Fried quotation philosophy" } ; ARTICLE: "fry.limitations" "Fried quotation limitations" -"As with " { $vocab-link "locals" } ", fried quotations cannot contain " { $link >r } " and " { $link r> } ". This is not a real limitation in practice, since " { $link dip } " can be used instead." ; +"As with " { $vocab-link "locals" } ", fried quotations cannot contain " { $link >r } " and " { $link r> } ". This is not a real limitation in practice, since " { $link dip } " can be used instead." +$nl +"An error thrown if a fried quotation contains calls to " { $link >r } " and " { $link r> } ":" +{ $subsection >r/r>-in-fry-error } ; ARTICLE: "fry" "Fried quotations" "The " { $vocab-link "fry" } " vocabulary implements " { $emphasis "fried quotation" } ". Conceptually, fried quotations are quotations with ``holes'' (more formally, " { $emphasis "fry specifiers" } "), and the holes are filled in when the fried quotation is pushed on the stack." diff --git a/basis/fry/fry-tests.factor b/basis/fry/fry-tests.factor index d4a3b8b734..0137e8be22 100644 --- a/basis/fry/fry-tests.factor +++ b/basis/fry/fry-tests.factor @@ -1,23 +1,20 @@ IN: fry.tests USING: fry tools.test math prettyprint kernel io arrays -sequences ; +sequences eval accessors ; [ [ 3 + ] ] [ 3 '[ _ + ] ] unit-test [ [ 1 3 + ] ] [ 1 3 '[ _ _ + ] ] unit-test -[ [ 1 + ] ] [ 1 [ + ] '[ _ @ ] ] unit-test +[ [ 1 [ + ] call ] ] [ 1 [ + ] '[ _ @ ] ] unit-test -[ [ 1 + . ] ] [ 1 [ + ] '[ _ @ . ] ] unit-test +[ [ 1 [ + ] call . ] ] [ 1 [ + ] '[ _ @ . ] ] unit-test -[ [ + - ] ] [ [ + ] [ - ] '[ @ @ ] ] unit-test +[ [ [ + ] [ - ] [ call ] dip call ] ] [ [ + ] [ - ] '[ @ @ ] ] unit-test -[ [ "a" write "b" print ] ] +[ [ "a" "b" [ write ] dip print ] ] [ "a" "b" '[ _ write _ print ] ] unit-test -[ [ 1 2 + 3 4 - ] ] -[ [ + ] [ - ] '[ 1 2 @ 3 4 @ ] ] unit-test - [ 1/2 ] [ 1 '[ [ _ ] dip / ] 2 swap call ] unit-test @@ -58,3 +55,10 @@ sequences ; [ { { { 3 } } } ] [ 3 '[ [ [ _ 1array ] call 1array ] call 1array ] call ] unit-test + +[ "USING: fry kernel ; f '[ >r _ r> ]" eval ] +[ error>> >r/r>-in-fry-error? ] must-fail-with + +[ { { "a" 1 } { "b" 2 } { "c" 3 } { "d" 4 } } ] [ + 1 2 3 4 '[ "a" _ 2array "b" _ 2array "c" _ 2array "d" _ 2array 4array ] call +] unit-test diff --git a/basis/fry/fry.factor b/basis/fry/fry.factor index 87c59e18a0..ac036f58ad 100644 --- a/basis/fry/fry.factor +++ b/basis/fry/fry.factor @@ -1,33 +1,37 @@ ! Copyright (C) 2008 Slava Pestov, Eduardo Cavazos. ! See http://factorcode.org/license.txt for BSD license. USING: kernel sequences combinators parser splitting math -quotations arrays make words ; +quotations arrays make words locals.backend summary sets ; IN: fry : _ ( -- * ) "Only valid inside a fry" throw ; : @ ( -- * ) "Only valid inside a fry" throw ; +ERROR: >r/r>-in-fry-error ; + ] + } case ; -: ((shallow-fry)) ( accum quot adder -- result ) - >r shallow-fry r> - append swap [ - [ prepose ] curry append - ] unless-empty ; inline +M: >r/r>-in-fry-error summary + drop + "Explicit retain stack manipulation is not permitted in fried quotations" ; -: (shallow-fry) ( accum quot -- result ) - [ 1quotation ] [ - unclip { - { \ _ [ [ curry ] ((shallow-fry)) ] } - { \ @ [ [ compose ] ((shallow-fry)) ] } - [ swap >r suffix r> (shallow-fry) ] - } case - ] if-empty ; +: check-fry ( quot -- quot ) + dup { >r r> load-locals get-local drop-locals } intersect + empty? [ >r/r>-in-fry-error ] unless ; -: shallow-fry ( quot -- quot' ) [ ] swap (shallow-fry) ; +: shallow-fry ( quot -- quot' ) + check-fry + [ dup \ @ = [ drop [ _ call ] ] [ 1array ] if ] map concat + { _ } split [ length 1- [ncurry] ] [ spread>quot ] bi prefix ; PREDICATE: fry-specifier < word { _ @ } memq? ; diff --git a/basis/generalizations/generalizations-tests.factor b/basis/generalizations/generalizations-tests.factor index 75985c9368..1ebe528f35 100644 --- a/basis/generalizations/generalizations-tests.factor +++ b/basis/generalizations/generalizations-tests.factor @@ -36,3 +36,5 @@ IN: generalizations.tests [ 1 2 3 4 ] [ { 1 2 3 4 } 4 firstn ] unit-test [ ] [ { } 0 firstn ] unit-test [ "a" ] [ { "a" } 1 firstn ] unit-test + +[ [ 1 2 ] ] [ 1 2 2 [ ] nsequence ] unit-test diff --git a/basis/generalizations/generalizations.factor b/basis/generalizations/generalizations.factor index 069d59cee1..c63c2b66ca 100644 --- a/basis/generalizations/generalizations.factor +++ b/basis/generalizations/generalizations.factor @@ -6,8 +6,11 @@ math.ranges combinators macros quotations fry arrays ; IN: generalizations MACRO: nsequence ( n seq -- quot ) - [ drop ] [ '[ _ _ new-sequence ] ] 2bi - [ '[ @ [ _ swap set-nth-unsafe ] keep ] ] reduce ; + [ + [ drop ] [ '[ _ _ new-sequence ] ] 2bi + [ '[ @ [ _ swap set-nth-unsafe ] keep ] ] reduce + ] keep + '[ @ _ like ] ; MACRO: narray ( n -- quot ) '[ _ { } nsequence ] ; diff --git a/basis/locals/locals-docs.factor b/basis/locals/locals-docs.factor index 35e0536530..18488ed1dd 100644 --- a/basis/locals/locals-docs.factor +++ b/basis/locals/locals-docs.factor @@ -132,8 +132,8 @@ $nl "Unlike some languages such as Python and Java, writing to mutable locals in outer scopes is fully supported and has the expected semantics." ; ARTICLE: "locals-limitations" "Limitations of locals" -"The first limitation is that the " { $link >r } " and " { $link r> } " words may not be used together with locals. Instead, use the " { $link dip } " combinator." -$nl +"The first limitation is also shared by " { $vocab-link "fry" } ": the " { $link >r } " and " { $link r> } " words may not be used together with locals. Instead, use the " { $link dip } " combinator. An error is thrown at parse time if an attempt is made to use " { $link >r } " and " { $link r> } " inside a lambda body:" +{ $subsection >r/r>-in-lambda-error } "Another limitation concerns combinators implemented as macros. Locals can only be used with such combinators if the input array immediately precedes the combinator call. For example, the following will work:" { $code ":: good-cond-usage ( a -- ... )" diff --git a/basis/locals/locals-tests.factor b/basis/locals/locals-tests.factor index 04e077fc4f..60e40b9629 100644 --- a/basis/locals/locals-tests.factor +++ b/basis/locals/locals-tests.factor @@ -2,7 +2,7 @@ USING: locals math sequences tools.test hashtables words kernel namespaces arrays strings prettyprint io.streams.string parser accessors generic eval combinators combinators.short-circuit combinators.short-circuit.smart math.order math.functions -definitions compiler.units ; +definitions compiler.units fry ; IN: locals.tests :: foo ( a b -- a a ) a a ; @@ -286,6 +286,8 @@ M:: sequence method-with-locals ( a -- y ) a reverse ; { [ a b > ] [ 5 ] } } cond ; +\ cond-test must-infer + [ 3 ] [ 1 2 cond-test ] unit-test [ 4 ] [ 2 2 cond-test ] unit-test [ 5 ] [ 3 2 cond-test ] unit-test @@ -293,6 +295,8 @@ M:: sequence method-with-locals ( a -- y ) a reverse ; :: 0&&-test ( a -- ? ) { [ a integer? ] [ a even? ] [ a 10 > ] } 0&& ; +\ 0&&-test must-infer + [ f ] [ 1.5 0&&-test ] unit-test [ f ] [ 3 0&&-test ] unit-test [ f ] [ 8 0&&-test ] unit-test @@ -301,6 +305,8 @@ M:: sequence method-with-locals ( a -- y ) a reverse ; :: &&-test ( a -- ? ) { [ a integer? ] [ a even? ] [ a 10 > ] } && ; +\ &&-test must-infer + [ f ] [ 1.5 &&-test ] unit-test [ f ] [ 3 &&-test ] unit-test [ f ] [ 8 &&-test ] unit-test @@ -346,6 +352,10 @@ M:: sequence method-with-locals ( a -- y ) a reverse ; { 3 1 } [| from to seq | T{ slice f from to seq } ] must-infer-as +ERROR: punned-class x ; + +[ T{ punned-class f 3 } ] [ 3 [| a | T{ punned-class f a } ] call ] unit-test + :: literal-identity-test ( -- a b ) { } V{ } ; @@ -390,6 +400,18 @@ M:: integer lambda-method-forget-test ( a -- b ) ; [ { [ 10 ] } ] [ 10 [| A | { [ A ] } ] call ] unit-test +[ + "USING: locals fry math ; [ 0 '[ [let | A [ 10 ] | A _ + ] ] ]" eval +] [ error>> >r/r>-in-fry-error? ] must-fail-with + +:: (funny-macro-test) ( obj quot -- ? ) obj { quot } 1&& ; inline +: funny-macro-test ( n -- ? ) [ odd? ] (funny-macro-test) ; + +\ funny-macro-test must-infer + +[ t ] [ 3 funny-macro-test ] unit-test +[ f ] [ 2 funny-macro-test ] unit-test + ! :: wlet-&&-test ( a -- ? ) ! [wlet | is-integer? [ a integer? ] ! is-even? [ a even? ] diff --git a/basis/locals/locals.factor b/basis/locals/locals.factor index 7de9d10436..1e205e10b0 100644 --- a/basis/locals/locals.factor +++ b/basis/locals/locals.factor @@ -6,12 +6,18 @@ quotations debugger macros arrays macros splitting combinators prettyprint.backend definitions prettyprint hashtables prettyprint.sections sets sequences.private effects effects.parser generic generic.parser compiler.units accessors -locals.backend memoize macros.expander lexer classes ; +locals.backend memoize macros.expander lexer classes summary ; IN: locals ! Inspired by ! http://cat-language.googlecode.com/svn/trunk/CatPointFreeForm.cs +ERROR: >r/r>-in-lambda-error ; + +M: >r/r>-in-lambda-error summary + drop + "Explicit retain stack manipulation is not permitted in lambda bodies" ; + > , ] } - { [ t ] [ free-vars* ] } - } cond ; +M: local-writer free-vars* "local-reader" word-prop , ; + +M: lexical free-vars* , ; + +M: quote free-vars* , ; M: object free-vars* drop ; -M: quotation free-vars* [ add-if-free ] each ; +M: quotation free-vars* [ free-vars* ] each ; -M: lambda free-vars* - [ vars>> ] [ body>> ] bi free-vars swap diff % ; +M: lambda free-vars* [ vars>> ] [ body>> ] bi free-vars swap diff % ; GENERIC: lambda-rewrite* ( obj -- ) @@ -201,6 +204,8 @@ M: special rewrite-literal? drop t ; M: array rewrite-literal? [ rewrite-literal? ] contains? ; +M: quotation rewrite-literal? [ rewrite-literal? ] contains? ; + M: hashtable rewrite-literal? drop t ; M: vector rewrite-literal? drop t ; @@ -215,17 +220,20 @@ GENERIC: rewrite-element ( obj -- ) [ rewrite-element ] each ; : rewrite-sequence ( seq -- ) - [ rewrite-elements ] [ length , ] [ , ] tri \ nsequence , ; + [ rewrite-elements ] [ length , ] [ 0 head , ] tri \ nsequence , ; M: array rewrite-element dup rewrite-literal? [ rewrite-sequence ] [ , ] if ; +M: quotation rewrite-element + dup rewrite-literal? [ rewrite-sequence ] [ , ] if ; + M: vector rewrite-element rewrite-sequence ; M: hashtable rewrite-element >alist rewrite-sequence \ >hashtable , ; M: tuple rewrite-element - [ tuple-slots rewrite-elements ] [ class , ] bi \ boa , ; + [ tuple-slots rewrite-elements ] [ class literalize , ] bi \ boa , ; M: local rewrite-element , ; @@ -243,6 +251,10 @@ M: tuple local-rewrite* rewrite-element ; M: hashtable local-rewrite* rewrite-element ; +M: word local-rewrite* + dup { >r r> } memq? + [ >r/r>-in-lambda-error ] [ call-next-method ] if ; + M: object lambda-rewrite* , ; M: object local-rewrite* , ; diff --git a/basis/macros/expander/expander.factor b/basis/macros/expander/expander.factor index 3666fa2423..cdd2b49d9c 100644 --- a/basis/macros/expander/expander.factor +++ b/basis/macros/expander/expander.factor @@ -37,9 +37,17 @@ M: wrapper expand-macros* wrapped>> literal ; [ '[ _ ndrop _ nnip call ] [ ] like ] 2map , \ dispatch , ] bi ; -: expand-macro ( quot -- ) - stack [ swap with-datastack >vector ] change - stack get pop >quotation end (expand-macros) ; +: word, ( word -- ) end , ; + +: expand-macro ( word quot -- ) + '[ + drop + stack [ _ with-datastack >vector ] change + stack get pop >quotation end (expand-macros) + ] [ + drop + word, + ] recover ; : expand-macro? ( word -- quot ? ) dup [ "transform-quot" word-prop ] [ "macro" word-prop ] bi or dup [ @@ -47,11 +55,9 @@ M: wrapper expand-macros* wrapped>> literal ; stack get length <= ] [ 2drop f f ] if ; -: word, ( word -- ) end , ; - M: word expand-macros* dup expand-dispatch? [ drop expand-dispatch ] [ - dup expand-macro? [ nip expand-macro ] [ + dup expand-macro? [ expand-macro ] [ drop word, ] if ] if ; diff --git a/basis/prettyprint/backend/backend.factor b/basis/prettyprint/backend/backend.factor index 2af0224e32..f1fd749666 100644 --- a/basis/prettyprint/backend/backend.factor +++ b/basis/prettyprint/backend/backend.factor @@ -216,27 +216,8 @@ M: object pprint* pprint-object ; M: vector pprint* pprint-object ; M: byte-vector pprint* pprint-object ; M: hashtable pprint* pprint-object ; - -GENERIC: valid-callable? ( obj -- ? ) - -M: object valid-callable? drop f ; - -M: quotation valid-callable? drop t ; - -M: curry valid-callable? quot>> valid-callable? ; - -M: compose valid-callable? - [ first>> ] [ second>> ] bi [ valid-callable? ] both? ; - -M: curry pprint* - dup valid-callable? [ pprint-object ] [ - "( invalid curry )" swap present-text - ] if ; - -M: compose pprint* - dup valid-callable? [ pprint-object ] [ - "( invalid compose )" swap present-text - ] if ; +M: curry pprint* pprint-object ; +M: compose pprint* pprint-object ; M: wrapper pprint* dup wrapped>> word? [ diff --git a/basis/prettyprint/prettyprint-tests.factor b/basis/prettyprint/prettyprint-tests.factor index 7fa3c5a1a3..96698fc18f 100644 --- a/basis/prettyprint/prettyprint-tests.factor +++ b/basis/prettyprint/prettyprint-tests.factor @@ -323,10 +323,6 @@ M: class-see-layout class-see-layout ; [ 2 break 2 \ + (step-into-execute) . ] (remove-breakpoints) ] unit-test -[ ] [ 1 \ + curry unparse drop ] unit-test - -[ ] [ 1 \ + compose unparse drop ] unit-test - GENERIC: generic-see-test-with-f ( obj -- obj ) M: f generic-see-test-with-f ; @@ -365,8 +361,3 @@ 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 ] unit-test - -[ "( invalid curry )" ] [ 1 2 curry unparse ] unit-test -[ "( invalid curry )" ] [ 1 2 3 curry curry unparse ] unit-test -[ "( invalid compose )" ] [ 1 2 compose unparse ] unit-test -[ "( invalid compose )" ] [ [ 1 ] 2 3 curry compose unparse ] unit-test diff --git a/core/bootstrap/primitives.factor b/core/bootstrap/primitives.factor index 20113d0e25..65731dd1ad 100644 --- a/core/bootstrap/primitives.factor +++ b/core/bootstrap/primitives.factor @@ -303,7 +303,13 @@ tuple [ f "inline" set-word-prop ] [ make-flushable ] [ ] - [ tuple-layout [ ] curry ] + [ + [ + callable instance-check-quot % + tuple-layout , + \ , + ] [ ] make + ] } cleave (( obj quot -- curry )) define-declared @@ -319,7 +325,16 @@ tuple [ f "inline" set-word-prop ] [ make-flushable ] [ ] - [ tuple-layout [ ] curry ] + [ + [ + \ >r , + callable instance-check-quot % + \ r> , + callable instance-check-quot % + tuple-layout , + \ , + ] [ ] make + ] } cleave (( quot1 quot2 -- compose )) define-declared diff --git a/core/classes/tuple/tuple.factor b/core/classes/tuple/tuple.factor index a56a4df029..70b189852f 100644 --- a/core/classes/tuple/tuple.factor +++ b/core/classes/tuple/tuple.factor @@ -121,7 +121,7 @@ ERROR: bad-superclass class ; [ \ dup , [ "predicate" word-prop % ] - [ [ bad-slot-value ] curry , ] bi + [ [ literalize , \ bad-slot-value , ] [ ] make , ] bi \ unless , ] [ ] make ; diff --git a/core/combinators/combinators.factor b/core/combinators/combinators.factor index 8cfa671a8b..82744276fd 100644 --- a/core/combinators/combinators.factor +++ b/core/combinators/combinators.factor @@ -28,10 +28,7 @@ IN: combinators ! spread : spread>quot ( seq -- quot ) - [ ] [ - [ dup empty? [ [ >r ] swap [ r> ] 3append ] unless ] dip - append - ] reduce ; + [ ] [ [ dup empty? [ [ dip ] curry ] unless ] dip append ] reduce ; : spread ( objs... seq -- ) spread>quot call ; diff --git a/core/parser/parser-tests.factor b/core/parser/parser-tests.factor index f621cbb84a..ca80533a2e 100644 --- a/core/parser/parser-tests.factor +++ b/core/parser/parser-tests.factor @@ -2,7 +2,7 @@ USING: arrays math parser tools.test kernel generic words io.streams.string namespaces classes effects source-files assocs sequences strings io.files definitions continuations sorting classes.tuple compiler.units debugger vocabs -vocabs.loader accessors eval combinators ; +vocabs.loader accessors eval combinators lexer ; IN: parser.tests [ diff --git a/core/quotations/quotations-tests.factor b/core/quotations/quotations-tests.factor index d311dfad71..29e1304334 100644 --- a/core/quotations/quotations-tests.factor +++ b/core/quotations/quotations-tests.factor @@ -15,4 +15,4 @@ IN: quotations.tests [ [ "hi" ] ] [ "hi" 1quotation ] unit-test -! [ 1 \ + curry ] must-fail +[ 1 \ + curry ] must-fail diff --git a/extra/boids/boids.factor b/extra/boids/boids.factor index 3d4cd392ca..eeebe1c12d 100644 --- a/extra/boids/boids.factor +++ b/extra/boids/boids.factor @@ -1,5 +1,5 @@ -USING: combinators.short-circuit kernel namespaces +USING: kernel namespaces math math.constants math.functions @@ -10,6 +10,7 @@ USING: combinators.short-circuit kernel namespaces math.physics.vel combinators arrays sequences random vars combinators.lib + combinators.short-circuit accessors ; IN: boids @@ -156,7 +157,7 @@ VAR: separation-radius 2&& ; : alignment-neighborhood ( self -- boids ) -boids> [ within-alignment-neighborhood? ] with filter ; + boids> [ within-alignment-neighborhood? ] with filter ; : alignment-force ( self -- force ) alignment-neighborhood diff --git a/extra/display-stack/display-stack.factor b/extra/display-stack/display-stack.factor deleted file mode 100644 index 98af43fec8..0000000000 --- a/extra/display-stack/display-stack.factor +++ /dev/null @@ -1,43 +0,0 @@ - -USING: kernel namespaces sequences math - listener io prettyprint sequences.lib bake bake.fry ; - -IN: display-stack - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -SYMBOL: watched-variables - -: watch-var ( sym -- ) watched-variables get push ; - -: watch-vars ( seq -- ) watched-variables get [ push ] curry each ; - -: unwatch-var ( sym -- ) watched-variables get delete ; - -: unwatch-vars ( seq -- ) watched-variables get [ delete ] curry each ; - -: print-watched-variables ( -- ) - watched-variables get length 0 > - [ - "----------" print - watched-variables get - watched-variables get [ unparse ] map longest length 2 + - '[ [ unparse ": " append , 32 pad-right write ] [ get . ] bi ] - each - - ] - when ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: display-stack ( -- ) - V{ } clone watched-variables set - [ - print-watched-variables - "----------" print - datastack [ . ] each - "----------" print - retainstack reverse [ . ] each - ] - listener-hook set ; - diff --git a/vm/math.c b/vm/math.c index 6a0acf7180..07493a947f 100644 --- a/vm/math.c +++ b/vm/math.c @@ -86,7 +86,7 @@ void primitive_fixnum_divmod(void) { F_FIXNUM y = get(ds); F_FIXNUM x = get(ds - CELLS); - if(y == -1 && x == tag_fixnum(FIXNUM_MIN)) + if(y == tag_fixnum(-1) && x == tag_fixnum(FIXNUM_MIN)) { put(ds - CELLS,allot_integer(-FIXNUM_MIN)); put(ds,tag_fixnum(0));