Clean up smart && and ||

db4
Slava Pestov 2008-08-26 20:40:19 -05:00
parent efb5553950
commit 47cb866891
1 changed files with 12 additions and 5 deletions

View File

@ -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 ;
<PRIVATE
MACRO: || ( quots -- quot )
dup first infer [ in>> ] [ 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 ;