diff --git a/library/tools/describe.factor b/library/tools/describe.factor index 5b0520b159..a58f689d5a 100644 --- a/library/tools/describe.factor +++ b/library/tools/describe.factor @@ -8,30 +8,32 @@ words ; GENERIC: sheet ( obj -- sheet ) : slot-sheet ( obj -- sheet ) - dup class "slots" word-prop - dup [ third ] map -rot - [ first slot ] map-with - 2array ; + dup class "slots" word-prop [ + dup third -rot first slot 2array + ] map-with ; M: object sheet ( obj -- sheet ) slot-sheet ; +M: tuple sheet ( tuple -- sheet ) + dup slot-sheet swap delegate [ 1 tail ] unless ; + M: sequence summary [ dup length # " element " % class word-name % ] "" make ; -M: quotation sheet 1array ; +: sequence-sheet [ 1array ] map ; -M: vector sheet 1array ; - -M: array sheet 1array ; +M: quotation sheet sequence-sheet ; +M: vector sheet sequence-sheet ; +M: array sheet sequence-sheet ; M: hashtable summary "a hashtable storing " swap hash-size number>string " keys" append3 ; -M: hashtable sheet hash>alist flip ; +M: hashtable sheet hash>alist ; : sheet. ( sheet -- ) - flip dup empty? [ + dup empty? [ drop ] [ dup first length 1 = diff --git a/library/tools/inspector.factor b/library/tools/inspector.factor index 3909d31bac..d89865ad04 100644 --- a/library/tools/inspector.factor +++ b/library/tools/inspector.factor @@ -1,16 +1,14 @@ ! Copyright (C) 2005 Slava Pestov. ! See http://factor.sf.net/license.txt for BSD license. IN: inspector -USING: arrays generic io kernel listener memory namespaces +USING: arrays generic io kernel listener math memory namespaces prettyprint sequences words ; SYMBOL: inspector-slots : sheet-numbers ( sheet -- sheet ) - dup empty? [ - dup first length >array 1array swap append - dup peek inspector-slots set - ] unless ; + dup [ peek ] map inspector-slots set + dup length [ 1+ add* ] 2map ; SYMBOL: inspector-stack @@ -40,9 +38,8 @@ SYMBOL: inspector-stack ] listener ; : inspect ( obj -- ) - #! Start an inspector if its not already running. inspector-stack get [ (inspect) ] [ inspector ] if ; -: go ( n -- ) inspector-slots get nth (inspect) ; +: go ( n -- ) 1- inspector-slots get nth (inspect) ; : up ( -- ) inspector-stack get dup pop* pop (inspect) ;