Subject: bug#11198: problems reading data with a "read-hash-extend" registered reader

From: [email-masked] (Ludovic Courtès)
Date: Sun, 22 Apr 2012 20:01:37 +0200

Hello!

I think the reader should only return valid Scheme objects that have a
read syntax (info "(r5rs) Lexical Structure"), and records are not among
them.

So a short-term solution would be to change ‘read-R’ to return the
expressions that builds the record, instead of the record itself–just
like macros return syntax objects, not arbitrary Scheme objects.

  (define (read-R chr port)
    (let ((rlst (read port)))
      (if (not (pair? rlst))
          #f
          (let* ((name (car rlst))
                 (lst (cdr rlst))
                 (rtd (primitive-eval name))
                 (fields (record-type-fields rtd)))
            `(apply (record-constructor name)
                    ,@(map (lambda (f)
                            ...)
                           fields))))))

We could imagine changing the compiler to be able to serialize records
in the future, but I think that’s a longer-term approach, and not
directly relevant to this report.

WDYT?

Ludo’.