Re: why generative? will@xxxxxx 04 Sep 2009 03:32 UTC

Shiro Kawai wrote:
> > Isn't that equivalent (modulo the use of 'nongenerative
> > instead of 'uid) to the recommended semantics for the 'uid
> > extension that's already described by the draft of SRFI 99?
>
> SRFI-99 says "The semantics of this extension [uid] is the
> same as described by R6RS".
>
> R6RS requires the system to check the rtd with the same uid
> must have the same field specs etc.  This *requires* some form
> of a global table that maps uid to existing rtds.  This is
> also the cause that the code must use lengthy and cryptic
> uids like GUID to avoid accidental conflict of uids.

So the difference is this:  When the uid option is used, and
the specified uid is the same for two different calls to
make-rtd but some other argument is different, then your
proposal would have the two calls return distinct record
type descriptors, while at least one of the analogous R6RS
calls to make-record-type-descriptor would raise an exception.

> In my suggestion, two rtds are different even if it has the
> same uids but different field specs.  A library can have
> a record type with nongenerative id 'Point and two fields
> x and y, and another library can have a record type with
> id 'Point and three fields x, y and z.  Two record types
> are distinct.  I don't think this will cause confusion.

I suspect it would, but there is plenty of precedent for
adding confusing features to a programming language, and
the current draft of SRFI 99 already follows that tradition
in some ways.

To make this more concrete, please clarify which of the
following examples would create equivalent record type
descriptors, which would be illegal, and so forth.

    (make-rtd 'foo '#(x y z))
    (make-rtd 'foo '#((immutable x) (immutable y) (immutable z)))
    (make-rtd 'foo '#(x (immutable y) z))
    (make-rtd 'foo '#(x (mutable y) z))

    (make-rtd 'foo '#(x y z) #f)
    (make-rtd 'foo '#((immutable x) (immutable y) (immutable z)) #f)
    (make-rtd 'foo '#(x (immutable y) z) #f)
    (make-rtd 'foo '#(x (mutable y) z) #f)

    (make-rtd 'foo '#(x y z) 'uid 'bar)
    (make-rtd 'foo '#((immutable x) (immutable y) (immutable z)) 'uid 'bar)
    (make-rtd 'foo '#(x (immutable y) z) 'uid 'bar)
    (make-rtd 'foo '#(x (mutable y) z) 'uid 'bar)

    (make-rtd 'baz '#(x y z))
    (make-rtd 'baz '#((immutable x) (immutable y) (immutable z)))
    (make-rtd 'baz '#(x (immutable y) z))
    (make-rtd 'baz '#(x (mutable y) z))

    (make-rtd 'baz '#(x y z) 'uid 'bar)
    (make-rtd 'baz '#((immutable x) (immutable y) (immutable z)) 'uid 'bar)
    (make-rtd 'baz '#(x (immutable y) z) 'uid 'bar)
    (make-rtd 'baz '#(x (mutable y) z) 'uid 'bar)

    (make-rtd 'baz '#(x y z) 'uid (list 'bar))
    (make-rtd 'baz '#((immutable x) (immutable y) (immutable z)) 'uid (list 'bar))
    (make-rtd 'baz '#(x (immutable y) z) 'uid (list 'bar))
    (make-rtd 'baz '#(x (mutable y) z) 'uid (list 'bar))

    (make-rtd 'baz '#(x y z) 'uid '(bar))
    (make-rtd 'baz '#((immutable x) (immutable y) (immutable z)) 'uid '(bar))
    (make-rtd 'baz '#(x (immutable y) z) 'uid '(bar))
    (make-rtd 'baz '#(x (mutable y) z) 'uid '(bar))

Will