From 9e685d7ac41c0fd907b08e6df7d2aec5d8a4e4c3 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 20 Jul 2008 01:15:58 -0500 Subject: [PATCH] Refactor curry/compose a bit for upcoming frontend changes --- core/bootstrap/primitives.factor | 21 ++++++++++++++------- core/quotations/quotations.factor | 12 ++++++++++-- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/core/bootstrap/primitives.factor b/core/bootstrap/primitives.factor index a6ebf13f4d..df1d7dfd1d 100755 --- a/core/bootstrap/primitives.factor +++ b/core/bootstrap/primitives.factor @@ -6,7 +6,8 @@ sequences strings vectors words quotations assocs layouts classes classes.builtin classes.tuple classes.tuple.private kernel.private vocabs vocabs.loader source-files definitions slots classes.union classes.intersection classes.predicate -compiler.units bootstrap.image.private io.files accessors combinators ; +compiler.units bootstrap.image.private io.files accessors +combinators ; IN: bootstrap.primitives "Creating primitives and basic runtime structures..." print flush @@ -310,9 +311,12 @@ tuple } prepare-slots define-tuple-class "curry" "kernel" lookup -[ f "inline" set-word-prop ] -[ ] -[ tuple-layout [ ] curry ] tri +{ + [ f "inline" set-word-prop ] + [ make-flushable ] + [ ] + [ tuple-layout [ ] curry ] tri +} cleave (( obj quot -- curry )) define-declared "compose" "kernel" create @@ -323,9 +327,12 @@ tuple } prepare-slots define-tuple-class "compose" "kernel" lookup -[ f "inline" set-word-prop ] -[ ] -[ tuple-layout [ ] curry ] tri +{ + [ f "inline" set-word-prop ] + [ make-flushable ] + [ ] + [ tuple-layout [ ] curry ] tri +} cleave (( quot1 quot2 -- compose )) define-declared ! Sub-primitive words diff --git a/core/quotations/quotations.factor b/core/quotations/quotations.factor index 9e7ded1836..617dac3323 100755 --- a/core/quotations/quotations.factor +++ b/core/quotations/quotations.factor @@ -5,11 +5,19 @@ kernel kernel.private math assocs quotations.private slots.private ; IN: quotations + + M: quotation call (call) ; -M: curry call dup 3 slot swap 4 slot call ; +M: curry call uncurry call ; -M: compose call dup 3 slot swap 4 slot slip call ; +M: compose call uncompose slip call ; M: wrapper equal? over wrapper? [ [ wrapped>> ] bi@ = ] [ 2drop f ] if ;