diff --git a/basis/functors/functors-tests.factor b/basis/functors/functors-tests.factor index 37ec1d3e15..b500d9f5ca 100644 --- a/basis/functors/functors-tests.factor +++ b/basis/functors/functors-tests.factor @@ -63,6 +63,24 @@ WHERE [ 4 ] [ 1 3 blah ] unit-test +<< + +FUNCTOR: symbol-test ( W -- ) + +W DEFINES ${W} + +WHERE + +SYMBOL: W + +;FUNCTOR + +"blorgh" symbol-test + +>> + +[ blorgh ] [ blorgh ] unit-test + GENERIC: some-generic ( a -- b ) ! Does replacing an ordinary word with a functor-generated one work? @@ -72,6 +90,7 @@ GENERIC: some-generic ( a -- b ) TUPLE: some-tuple ; : some-word ( -- ) ; M: some-tuple some-generic ; + SYMBOL: some-symbol "> "functors-test" parse-stream ] unit-test @@ -82,6 +101,7 @@ GENERIC: some-generic ( a -- b ) "some-tuple" "functors.tests" lookup "some-generic" "functors.tests" lookup method >boolean ] unit-test ; + [ t ] [ "some-symbol" "functors.tests" lookup >boolean ] unit-test test-redefinition @@ -90,12 +110,14 @@ FUNCTOR: redefine-test ( W -- ) W-word DEFINES ${W}-word W-tuple DEFINES-CLASS ${W}-tuple W-generic IS ${W}-generic +W-symbol DEFINES ${W}-symbol WHERE TUPLE: W-tuple ; : W-word ( -- ) ; M: W-tuple W-generic ; +SYMBOL: W-symbol ;FUNCTOR @@ -105,4 +127,5 @@ M: W-tuple W-generic ; "> "functors-test" parse-stream ] unit-test -test-redefinition \ No newline at end of file +test-redefinition + diff --git a/basis/functors/functors.factor b/basis/functors/functors.factor index 309154fb49..fc502a5695 100644 --- a/basis/functors/functors.factor +++ b/basis/functors/functors.factor @@ -5,7 +5,7 @@ words interpolate namespaces sequences io.streams.string fry classes.mixin effects lexer parser classes.tuple.parser effects.parser locals.types locals.parser generic.parser locals.rewrite.closures vocabs.parser classes.parser -arrays accessors ; +arrays accessors words.symbol ; IN: functors ! This is a hack @@ -80,6 +80,10 @@ SYNTAX: `: parse-declared* \ define-declared* parsed ; +SYNTAX: `SYMBOL: + scan-param parsed + \ define-symbol parsed ; + SYNTAX: `SYNTAX: scan-param parsed parse-definition* @@ -116,6 +120,7 @@ DEFER: ;FUNCTOR delimiter { ":" POSTPONE: `: } { "INSTANCE:" POSTPONE: `INSTANCE: } { "SYNTAX:" POSTPONE: `SYNTAX: } + { "SYMBOL:" POSTPONE: `SYMBOL: } { "inline" POSTPONE: `inline } } ;