2008-07-02 01:20:01 -04:00
|
|
|
! Copyright (C) 2008 Slava Pestov.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2012-07-22 17:36:51 -04:00
|
|
|
USING: accessors assocs classes continuations kernel make math
|
|
|
|
math.parser sequences ;
|
2008-07-02 01:20:01 -04:00
|
|
|
IN: summary
|
|
|
|
|
|
|
|
GENERIC: summary ( object -- string )
|
|
|
|
|
|
|
|
: object-summary ( object -- string )
|
2012-09-21 14:36:04 -04:00
|
|
|
class-of name>> ; inline
|
2008-07-02 01:20:01 -04:00
|
|
|
|
|
|
|
M: object summary object-summary ;
|
|
|
|
|
|
|
|
M: sequence summary
|
|
|
|
[
|
2011-10-24 07:47:42 -04:00
|
|
|
dup class-of name>> %
|
2008-07-02 01:20:01 -04:00
|
|
|
" with " %
|
|
|
|
length #
|
|
|
|
" elements" %
|
|
|
|
] "" make ;
|
|
|
|
|
|
|
|
M: assoc summary
|
|
|
|
[
|
2011-10-24 07:47:42 -04:00
|
|
|
dup class-of name>> %
|
2008-07-02 01:20:01 -04:00
|
|
|
" with " %
|
|
|
|
assoc-size #
|
|
|
|
" entries" %
|
|
|
|
] "" make ;
|
|
|
|
|
|
|
|
! Override sequence => integer instance
|
|
|
|
M: f summary object-summary ;
|
|
|
|
|
|
|
|
M: integer summary object-summary ;
|
2012-07-22 17:36:51 -04:00
|
|
|
|
|
|
|
: safe-summary ( object -- string )
|
|
|
|
[ summary ]
|
|
|
|
[ drop object-summary "~summary error: " "~" surround ]
|
|
|
|
recover ;
|