From db81422ff43572e6b5962411f2e6aaa324658b07 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Mon, 15 Apr 2013 11:27:09 -0700 Subject: [PATCH] infix: crazy infix methods idea, dunno if it is awesome yet. --- extra/infix/infix-tests.factor | 4 ++++ extra/infix/infix.factor | 22 ++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/extra/infix/infix-tests.factor b/extra/infix/infix-tests.factor index 8a729aa344..1c54de3a91 100644 --- a/extra/infix/infix-tests.factor +++ b/extra/infix/infix-tests.factor @@ -50,3 +50,7 @@ IN: infix.tests [ "rbo" ] [ [let "foobar" :> s [infix s[::-2] infix] ] ] unit-test [ "rbo" ] [ [let "foobar" :> s [infix s[:0:-2] infix] ] ] unit-test [ "rb" ] [ [let "foobar" :> s [infix s[:-5:-2] infix] ] ] unit-test + +INFIX:: foo ( x y -- z ) x**2-abs(y); + +{ 194 } [ 15 31 foo ] unit-test diff --git a/extra/infix/infix.factor b/extra/infix/infix.factor index 8b15f1f364..b81dc1db62 100644 --- a/extra/infix/infix.factor +++ b/extra/infix/infix.factor @@ -1,11 +1,9 @@ ! Copyright (C) 2009 Philipp Brüschweiler ! See http://factorcode.org/license.txt for BSD license. -USING: accessors assocs combinators combinators.short-circuit -effects fry infix.parser infix.ast kernel locals locals.parser -locals.types math math.functions math.order math.ranges -multiline namespaces parser quotations sequences summary -words vocabs.parser ; - +USING: accessors assocs combinators effects effects.parser fry +infix.ast infix.parser kernel locals locals.parser math +math.functions math.order math.ranges multiline namespaces +parser quotations sequences summary words ; IN: infix SYNTAX: [infix "infix]" parse-infix-quotation suffix! \ call suffix! ; + + + +SYNTAX: INFIX:: (INFIX::) define-declared ;