[R6RS] Re: Zapping SET-CAR! & SET-CDR!

Marc Feeley feeley
Tue Oct 26 13:04:55 EDT 2004


> > Moreover, as I pointed out at the workshop, the #n= and
> > #n# syntaxes for shared structures that contain lists, could not be
> > implemented in Scheme (you need set-car! and set-cdr! for that).
> 
> Actually, the #n=/#n# syntaxes can be implemented for shared structure and
> any cyclic structure that can be created by mutating some mutable object.
> For example, (#1=(a b c) #1#) is no problem, and both #1=#((#1#)) and
> #1=(#(#1#)) can be created by mutating the vector instead of the pair.
> Chez Scheme's reader already has to deal with this issue to handle marks
> and references in immutable record fields, and it's not a big deal.

I'm not sure I understand the "not a big deal".  Do you mean that the
underlying implementation language can be Scheme with set-ca/dr! and
mutators for immutable record fields (to implement the #n# syntax) but
set-ca/dr! is not available to the user?  All I'm saying is that in
this case "read" can no longer be written in Scheme and has to be
viewed as a primitive.

> All we'd be losing is the ability to create cycles that can only be
> created by mutating immutable fields.  This is just a natural consequence
> of the immutability.

It is the case (#1# #1=(a b c)) I am worried about.  It is true
that you could make multiple passes on the input to avoid set-car!
in this case.  However, this can't be handled without set-car!:

   #1=(a b #1# c)

You could specify that this is an error, but that would be strange because
the following very similar datums would be acceptable:

   #1=#(a b #1# c)

and

   #1=(a b #(#1#) c)

and

   (#1=(a b) #1# c)

So is the proposal to

  - get rid of set-ca/dr! and keep the possibility of circular lists
  - get rid of set-ca/dr! and the possibility of circular lists

Marc


More information about the R6RS mailing list