Email list hosting service & mailing list manager


Re: why generative? Shiro Kawai 06 Sep 2009 04:00 UTC

>From: xxxxxx@ccs.neu.edu
Subject: Re: why generative?
Date: Thu, 3 Sep 2009 23:32:10 -0400 (EDT)

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

Yes.  The sole purpose of the proposal is to eliminate the
requirement of separate implicit namespace; if there's other
way to achieve the same goal, I won't stick to my proposal.

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

Note 1: My original proposal to allow arbitrary object
for uid is to enable generative behavior in defualt-nongenerative
semantics.  If we go with default-generative, I think we can
restrict uid for symbols.

Note 2: In the following, I assume a field specifier
that consists of a symbol <name> is canonicalized to
(mutable <name>).

> 1. (make-rtd 'foo '#(x y z))
> 2. (make-rtd 'foo '#((immutable x) (immutable y) (immutable z)))
> 3. (make-rtd 'foo '#(x (immutable y) z))
> 4. (make-rtd 'foo '#(x (mutable y) z))

With default-generative semantics, all expressions
generate distinct record types.

With default-nongenerative semantics, 1 and 4 returns
the equivalent rtd (because of canonicalization).
1, 2, 3 are all distinct.

> 5.  (make-rtd 'foo '#(x y z) #f)
> 6.  (make-rtd 'foo '#((immutable x) (immutable y) (immutable z)) #f)
> 7.  (make-rtd 'foo '#(x (immutable y) z) #f)
> 8.  (make-rtd 'foo '#(x (mutable y) z) #f)

With default-generative semantics, all expressions
generate distinct record types.

With default-nongenerative semantics, 5 and 8 returns
the equivalent rtd (because of canonicalization).
It is also equivalent to 1 and 4.

> 9.  (make-rtd 'foo '#(x y z) 'uid 'bar)
> 10. (make-rtd 'foo '#((immutable x) (immutable y) (immutable z)) 'uid 'bar)
> 11. (make-rtd 'foo '#(x (immutable y) z) 'uid 'bar)
> 12. (make-rtd 'foo '#(x (mutable y) z) 'uid 'bar)

Both with default-generative and default-nongenerative semantics,
9 and 12 returns the equivalent rtd, which is differnt from all
other rtds generated so far.

> 13. (make-rtd 'baz '#(x y z))
> 14. (make-rtd 'baz '#((immutable x) (immutable y) (immutable z)))
> 15. (make-rtd 'baz '#(x (immutable y) z))
> 16. (make-rtd 'baz '#(x (mutable y) z))

With default-generative semantics, every one returns a new
rtd which is different from all other rtds generated so far.

With default-nongenerative semantics, 13 and 16 returns the
same rtd.  Rtds from 13, 14 and 15 are different from each
other, and different from all rtds generated so far.

> 17. (make-rtd 'baz '#(x y z) 'uid 'bar)
> 18. (make-rtd 'baz '#((immutable x) (immutable y) (immutable z)) 'uid 'bar)
> 19. (make-rtd 'baz '#(x (immutable y) z) 'uid 'bar)
> 20. (make-rtd 'baz '#(x (mutable y) z) 'uid 'bar)

Both with default-generative and default-nongenerative
semantics, 17 and 20 returns the same rtd.
Except that, all rtds are different from each other.

> 21. (make-rtd 'baz '#(x y z) 'uid (list 'bar))
> 22. (make-rtd 'baz '#((immutable x) (immutable y) (immutable z)) 'uid (list 'bar))
> 23. (make-rtd 'baz '#(x (immutable y) z) 'uid (list 'bar))
> 24. (make-rtd 'baz '#(x (mutable y) z) 'uid (list 'bar))

With default-generative semantics they are errors
(uid isn't a symbol.)

With default-nongenerative semantics, each one returns
a unique rtd.  It is guaranteeed to be different from
any other rtds.

> 25. (make-rtd 'baz '#(x y z) 'uid '(bar))
> 26. (make-rtd 'baz '#((immutable x) (immutable y) (immutable z)) 'uid '(bar))
> 27. (make-rtd 'baz '#(x (immutable y) z) 'uid '(bar))
> 28. (make-rtd 'baz '#(x (mutable y) z) 'uid '(bar))

With default-generative semantics they are errors
(uid isn't a symbol.)

With default-nongenerative semantics, 25, 26, and 27
returns new rtds, different from each other and from
any one of rtds generated so far.
Rtd from 28 may or may not the same as 25; depending
how the implementation treats literal list.

--shiro