         #out unpacker %
     ] [ ] make ;
 
+ERROR: too-many-arguments ;
+
+M: too-many-arguments summary
+    drop "There must be no more than 4 input and 4 output arguments" ;
+
 : check-memoized ( word -- )
-    dup #in 4 > swap #out 4 > or [
-        "There must be no more than 4 input and 4 output arguments" throw
-    ] when ;
+    dup #in 4 > swap #out 4 > or [ too-many-arguments ] when ;
 
 : define-memoized ( word quot -- )
     over check-memoized

! Copyright (C) 2007 Slava Pestov, Daniel Ehrenberg.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel hashtables sequences arrays words namespaces
parser math assocs effects definitions quotations ;
IN: memoize

: packer ( n -- quot )

    { [ drop ] [ ] [ first2 ] [ first3 ] [ first4 ] } nth ;

: #in ( word -- n )
    stack-effect in>> length ;

: #out ( word -- n )
    stack-effect out>> length ;

: pack/unpack ( quot word -- newquot )
    [ dup #in unpacker % swap % #out packer % ] [ ] make ;
