bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Ludovic Courtès
Subject: bug#11198: problems reading data with a "read-hash-extend" registered reader
Date: Sun, 22 Apr 2012 20:01:37 +0200
User-agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.93 (gnu/linux)

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’.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]