[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: immutable pairs in existing implementations

This page is part of the web mail archives of SRFI 116 from before July 7th, 2015. The new archives for SRFI 116 contain all messages, not just those from before July 7th, 2015.



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        cowan@xxxxxxxx
"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."