GNU bug report logs - #11198
serializing structs (prefabs)

Previous Next

Package: guile;

Reported by: Klaus Stehle <klaus.stehle <at> uni-tuebingen.de>

Date: Sat, 7 Apr 2012 20:18:02 UTC

Severity: wishlist

Full log


View this message in rfc822 format

From: ludo <at> gnu.org (Ludovic Courtès)
To: Mark H Weaver <mhw <at> netris.org>
Cc: Andy Wingo <wingo <at> pobox.com>, 11198 <at> debbugs.gnu.org, Klaus Stehle <klaus.stehle <at> uni-tuebingen.de>
Subject: bug#11198: problems reading data with a "read-hash-extend" registered reader
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’.




This bug report was last modified 12 years and 202 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.