From 6198ba2c3c7517bc5decfcfd078cf61218c0148b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Sat, 20 May 2017 01:17:50 +0200 Subject: [PATCH] Added `reset?` option to print-full-scopes --- scribblings/debug-scopes.scrbl | 13 +++++++++---- superscripts.rkt | 7 ++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/scribblings/debug-scopes.scrbl b/scribblings/debug-scopes.scrbl index 8090f96..7c95f09 100644 --- a/scribblings/debug-scopes.scrbl +++ b/scribblings/debug-scopes.scrbl @@ -64,13 +64,18 @@ (foo (list 123))]} -@defproc[(print-full-scopes) void?]{ Prints the long scope id and annotation - for all scopes displayed as part of preceeding calls to @racket[+scopes], as - would be shown by @racket[(hash-ref (syntax-debug-info stx) 'context)]. +@defproc[(print-full-scopes [reset? any/c #t]) void?]{ Prints the long scope id + and annotation for all scopes displayed as part of preceeding calls to + @racket[+scopes], as would be shown by + @racket[(hash-ref (syntax-debug-info stx) 'context)]. This allows to get some extended information about the scopes in a summary table by calling @racket[print-full-scopes], while still getting short and - readable display of syntax objects with @racket[+scopes].} + readable display of syntax objects with @racket[+scopes]. + + After running @racket[(print-full-scopes)], if @racket[reset?] is true, then + the scope counter is reset (and @racket[+scopes] therefore starts numbering + scopes starting from @racket[0] again).} @section{Hack for named scopes} diff --git a/superscripts.rkt b/superscripts.rkt index 21861b8..7667b45 100644 --- a/superscripts.rkt +++ b/superscripts.rkt @@ -10,7 +10,7 @@ (define max-seen-scopes 0) (define seen-scopes (make-hash)) -(define (print-full-scopes) +(define (print-full-scopes [reset? #t]) (define scopes (sort (hash->list seen-scopes) < #:key cadr)) (define l (map (λ (s) @@ -30,8 +30,9 @@ (vector-ref (cddr s) 0))) scopes l) - (hash-clear! seen-scopes) - (set! max-seen-scopes 0)) + (when reset? + (hash-clear! seen-scopes) + (set! max-seen-scopes 0))) (define (string-replace* str replacements) (if (null? replacements)