guile-devel
[Top][All Lists]
Advanced

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

Re: records as s-expressions


From: Marius Vollmer
Subject: Re: records as s-expressions
Date: Thu, 16 Oct 2003 22:48:26 +0200
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux)

Thamer Al-Harbash <address@hidden> writes:

> On Thu, 16 Oct 2003, Marius Vollmer wrote:
>
>> Yes.
>>
>> One other thing that just occured to me: how does 'read' find the
>> record creator from the type name?
>
> Good point. I can't see how this would work by putting it in the
> reader.

Me neither.  We can't easily solve the general problem (writing _all_
record types in a readable way by default), but we could make it easy
for the user to implement readable writing for selected record types.

Something like this:

  (define r (make-record-type foo '(a b) readable-record-printer))
  (register-record-reader 'foo foo)

where readable-record-printer will print a record as

  #,(foo a: ... b: ...)

and register-record-reader will use define-reader-ctor to be able to
read the record back in.

> Here's the real problem though:

That's not serious: this only happens because the default record
printer uses display instead of write.

> However a problem occurs when dealing with SMOBs or types which
> (read) cannot convert properly.  How is this dealt with in data
> types like arrays? If I print an array, which contains smobs or
> records, from the REPL, how is it converted back when (read) gets it
> again?

This is a separate problem; we don't need to solve it right now.

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405




reply via email to

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