[plt-scheme] Problem with prop:custom-write

From: Erich Rast (erich at snafu.de)
Date: Tue Nov 22 05:26:34 EST 2005

Hi,

Can anyone tell me what's wrong with the following code?

   (define (print-internal-label lab port write?)
      (let ((idx (internal-label-ref lab 1))
            (sym (internal-label-ref lab 0)))
        (when write? (write-string "#<label:" port))
        ((if write? write display) sym port)
        (when idx
          (write-string "-" port)
          ((if write? write display) idx port))
        (when write? (write-string ">" port))))

    (define-values
     (struct:internal-label make-internal-label internal-label? 
internal-label-ref internal-label-set!)
     (make-struct-type 'internal-label #f 1 0 #f
                       (list (cons prop:custom-write 
print-internal-label))))

   (define internal-label-symbol (make-struct-field-accessor 
struct:internal-label 0))
   (define internal-label-index (make-struct-field-accessor 
struct:internal-label 1))

Execution enters an infinite display loop and makes DrScheme freeze. I 
want the same as (define-struct internal-label (symbol index)), but 
with a customized display and write handler.

Best regards,

Erich



Posted on the users mailing list.