Email list hosting service & mailing list manager

immutable pairs in existing implementations Per Bothner (17 Sep 2014 16:50 UTC)
Re: immutable pairs in existing implementations John Cowan (17 Sep 2014 17:45 UTC)
Re: immutable pairs in existing implementations Per Bothner (18 Sep 2014 07:10 UTC)

Re: immutable pairs in existing implementations John Cowan 17 Sep 2014 17:45 UTC

Per Bothner scripsit:

> It seems very desirable to use the existing immutable pair data
> structures for SRFI-116 immutable pairs.  However, SRFI-116 causes
> some problems.

I think all the problems are in the realm of what Anglo-American lawyers
call "dictum"; that is, they are pronouncements by a judge on matters
which are not part of the issues currently being decided.  AFAICT, the
only such dicta are the claim that `pair?` returns #f on an immutable
pair, and that `write` should not output immutable lists as lists.  I'm
going to remove these and extend the specification to discuss how this
SRFI should work on Schemes that treat quoted lists as immutable.

> Consider the analogy with immutable and immutable strings.  Functions
> like string-ref can be applied to either kind of string.  It seems
> reasonable to let car and cdr apply to both mutable and immutable
> strings, at least as an implementation option.

That is already the case for R[457]RS, because implementations are
allowed to extend the domain of the standard procedures.  It is also
true for R6RS if the implementation treats quoted lists as immutable.
I don't think there's anything further to say here.

> In an implementation with "native" immutable pairs, a quoted list
> should return an immutable list.  For consistency, a quasi-quoted list
> should also return an immutable list.

Same comment.

> For quote/read identity (which is not essential but is desirable,
> especially if you might have circular lists) read should be allowed to
> return an immutable list.

I see that Kawa does so, but I think it's not conformant to RnRS: the (
... ) syntax in `read` should return mutable lists.

--
John Cowan          http://www.ccil.org/~cowan        xxxxxx@ccil.org
"But I am the real Strider, fortunately," he said, looking down at them
with his face softened by a sudden smile.  "I am Aragorn son of Arathorn,
and if by life or death I can save you, I will."