www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 6198ba2c3c7517bc5decfcfd078cf61218c0148b
parent 1b249efb878af409e3939aa296581785080d6367
Author: Georges Dupéron <georges.duperon@gmail.com>
Date:   Sat, 20 May 2017 01:17:50 +0200

Added `reset?` option to print-full-scopes

Diffstat:
Mscribblings/debug-scopes.scrbl | 13+++++++++----
Msuperscripts.rkt | 7++++---
2 files changed, 13 insertions(+), 7 deletions(-)

diff --git 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 @@ -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)