[Top][All Lists]

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

Re: records as s-expressions

From: Thamer Al-Harbash
Subject: Re: records as s-expressions
Date: Thu, 16 Oct 2003 15:59:21 -0400 (EDT)

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. Here's the real problem though:

Currently a record of type "foobar" with two fields "foo" and
"bar" will print as such:

#<foobar foo: 1 bar: 2>

The problem here is that you cannot tell the whether those datums
hold strings or numerics:

guile> ((record-constructor (make-record-type "foobar" '(foo bar))) 1 2)
#<foobar foo: 1 bar: 2>

guile> ((record-constructor (make-record-type "foobar" '(foo bar))) "1" "2")
#<foobar foo: 1 bar: 2>

The simple solution is to store type information as a symbol so
this distinction can be made:

#<foobar foo: type-string: 1 bar: type-string: 2>

This should be enough for me to create the record type, and a
constructor in the hash extension hook.

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?

Thamer Al-Harbash
GPG Key fingerprint: D7F3 1E3B F329 8DD5 FAE3  03B1 A663 E359 D686 AA1F

reply via email to

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