From fc3197d73f8556a8ae5d8a8efea8babcca365dd0 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Thu, 6 May 2010 18:01:21 -0600 Subject: [PATCH] document latest printing convention original commit: e5a259bdf03ec96cd0227743788d19d2ffd7f871 --- collects/scribble/racket.rkt | 50 ++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/collects/scribble/racket.rkt b/collects/scribble/racket.rkt index e277f8b9..836c9355 100644 --- a/collects/scribble/racket.rkt +++ b/collects/scribble/racket.rkt @@ -442,7 +442,7 @@ (set! src-col (syntax-column (cadr l))) (hash-set! next-col-map src-col dest-col) (set! highlight? #t) - ((loop init-line! quote-depth expr?) (cadr l) #f) + ((loop init-line! quote-depth expr? #f) (cadr l)) (set! highlight? h?) (set! src-col (add1 src-col)))] [(and (pair? (syntax-e c)) @@ -979,27 +979,33 @@ (define-struct forced-pair (car cdr)) (define (quotable? v) - (cond - [(syntax? v) (quotable? (syntax-e v))] - [(pair? v) (and (quotable? (car v)) - (quotable? (cdr v)))] - [(vector? v) (andmap quotable? (vector->list v))] - [(hash? v) (for/and ([(k v) (in-hash v)]) - (and (quotable? k) - (quotable? v)))] - [(box? v) (quotable? (unbox v))] - [(and (struct? v) - (prefab-struct-key v)) - (andmap quotable? (vector->list (struct->vector v)))] - [(struct? v) (if (custom-write? v) - (if (and (custom-print-as-constructor? v) - (custom-print-as-constructor-accessor v)) - #f - #t) - #f)] - [(struct-proxy? v) #f] - [(mpair? v) #f] - [else #t])) + (define graph (make-hasheq)) + (let quotable? ([v v]) + (if (hash-ref graph v #f) + #t + (begin + (hash-set! graph v #t) + (cond + [(syntax? v) (quotable? (syntax-e v))] + [(pair? v) (and (quotable? (car v)) + (quotable? (cdr v)))] + [(vector? v) (andmap quotable? (vector->list v))] + [(hash? v) (for/and ([(k v) (in-hash v)]) + (and (quotable? k) + (quotable? v)))] + [(box? v) (quotable? (unbox v))] + [(and (struct? v) + (prefab-struct-key v)) + (andmap quotable? (vector->list (struct->vector v)))] + [(struct? v) (if (custom-write? v) + (if (and (custom-print-as-constructor? v) + (custom-print-as-constructor-accessor v)) + #f + #t) + #f)] + [(struct-proxy? v) #f] + [(mpair? v) #f] + [else #t]))))) (define (do-syntax-ize v col line ht graph? qq no-cons?) (cond