From 47cb8668910b3db3e11ef682056a7787d54a6420 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 26 Aug 2008 20:40:19 -0500 Subject: [PATCH] Clean up smart && and || --- .../short-circuit/smart/smart.factor | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/basis/combinators/short-circuit/smart/smart.factor b/basis/combinators/short-circuit/smart/smart.factor index 141077ea3a..ca659cacbe 100644 --- a/basis/combinators/short-circuit/smart/smart.factor +++ b/basis/combinators/short-circuit/smart/smart.factor @@ -1,11 +1,18 @@ -USING: kernel sequences math stack-checker accessors macros +USING: kernel sequences math stack-checker effects accessors macros combinators.short-circuit ; IN: combinators.short-circuit.smart -MACRO: && ( quots -- quot ) - dup first infer [ in>> ] [ out>> ] bi - 1+ n&&-rewrite ; +> ] [ out>> ] bi - 1+ n||-rewrite ; +: arity ( quots -- n ) + first infer + dup terminated?>> [ "Cannot determine arity" throw ] when + effect-height neg 1+ ; + +PRIVATE> + +MACRO: && ( quots -- quot ) dup arity n&&-rewrite ; + +MACRO: || ( quots -- quot ) dup arity n||-rewrite ;