Newsgroups: comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!godot.cc.duq.edu!newsgate.duke.edu!news.mathworks.com!newsfeed.internetmci.com!swrinde!sdd.hp.com!col.hp.com!cello.hpl.hp.com!hplntx!hplntx.hpl.hp.com!gjr
From: gjr@hplgr2.hpl.hp.com (Guillermo (Bill) J. Rozas)
Subject: Re: constants and eq?
Sender: news@hpl.hp.com (HPLabs Usenet Login)
Message-ID: <GJR.96Jun11104125@hplgr2.hpl.hp.com>
In-Reply-To: four@ural.owlnet.rice.edu's message of 11 Jun 1996 15:04:54 GMT
Date: Tue, 11 Jun 1996 17:41:25 GMT
Reply-To: gjr@hpl.hp.com
References: <QOBI.96Jun9154415@eesun.technion.ac.il> <4pk1um$oac@larry.rice.edu>
Nntp-Posting-Host: hplgr2.hpl.hp.com
Organization: Hewlett-Packard Laboratories, Palo Alto, CA
Lines: 51

In article <4pk1um$oac@larry.rice.edu> four@ural.owlnet.rice.edu (Sebastian Erich Good) writes:

|   From: four@ural.owlnet.rice.edu (Sebastian Erich Good)
|   Date: 11 Jun 1996 15:04:54 GMT
|   Newsgroups: comp.lang.scheme
|
|   In article <QOBI.96Jun9154415@eesun.technion.ac.il>,
|   Jeffrey Mark Siskind <Qobi@EE.Technion.AC.IL> wrote:
|   >I am trying to read R4RS with a lawyer's eye. Can someone tell me whether
|   >the following must return #t or whether it is allowed to return #f:
|   >
|   >(define (c) '(a))
|   >(eq? (c) (c))
|   >
|
|   The two relelvant sections (4.1.2-Literal Expressions & 6.2-Equivalence 
|   predicates) seem to be silent on this issue, but leave two hints.  Most 
|   revealing to me is the specification for eq? which says:
|
|   (eq? '(a) '(a)) -> unspecified
|   (eq? (list 'a) (list 'a)) -> #f
|
|   Meaning that the authors left the possibility open for a compiler that 
|   did not just do a simple expansion as you suggest.
|   The other hint is that literal expressions of any sort are not to be 
|   modified by side-effecting procedures.  Since we might be free to return 
|   #f in the above unspecified example, we must be able to block destructive 
|   operations on those literal expressions, lest somebody figure out that 
|   they really are eq?.

The two examples are driving a very different point.

The point of the first,

	(eq? '(a) '(a))	-> unspecified

is that whether the reader/compiler unifies such isomorphic literals
is up to the implementation.

Traditionally such constants are created afresh by the reader every
time the character sequence is read.  Thus the two objects would not
be eq?  However, it is allowed for compilers to unify them since
it is illegal to mutate them.  There are compilers that do this.

The point of the second example is to guarantee that explicit
constructions are not unified.  Each invocation of cons/list,
etc. allocates fresh structure that can be mutated independently.

Thus the goal in the document was to allow the unification of
structured constants, but I'm pretty sure that splitting them (as in
the original question) was not a goal.
