guile-devel
[Top][All Lists]
Advanced

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

Re: Guile: What's wrong with this?


From: Mark H Weaver
Subject: Re: Guile: What's wrong with this?
Date: Sun, 08 Jan 2012 00:05:34 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

Hi Ian!

Ian Price <address@hidden> writes:

> Mark H Weaver <address@hidden> writes:
>
>> As I understand it, in the Scheme standards (at least before R6RS's
>> immutable pairs) the rationale behind marking literal constants as
>> immutable is solely to avoid needlessly making copies of those literals,
>> while flagging accidental attempts to modify them, since that is almost
>> certainly a mistake.
> Erm, if you don't count literals, which were already immutable, then
> R6RS doesn't have immutable pairs. It does move the mutators to a
> separate module, but that is a not really equivalent, because even if
> you don't import (rnrs mutable-pairs), another module may mutate pairs
> returned by your library. Ditto for strings,etc.
>
> To quote section 5.10
> "Literal constants, the strings returned by symbol->string, records with
> no mutable fields, and other values explicitly designated as immutable
> are immutable objects, while all objects created by the other procedures
> listed in this report are mutable."

Ah, I guess you're right.  I never studied the R6RS carefully outside of
its handling of numerics.  I wrote "at least before R6RS" to indicate
that I was only knowledgeable about earlier versions.

Racket's immutable pairs represent a break in the older tradition.  Last
I looked anyway, Racket's mutable pairs cannot even be accessed with the
standard `car' and `cdr'.  Therefore, they really are a different (and
incompatible) type from mutable pairs.

I still suspect that the rationale behind immutable pairs in the R6RS is
to discourage mutation of pairs, to give compiler implementations such
as Racket the freedom to make pairs truly immutable as thus benefit from
better optimizer.  However, I mistakenly implied that immutable pairs
were a distinct type in the R6RS itself, and for that I apologize.

    Thanks,
      Mark



reply via email to

[Prev in Thread] Current Thread [Next in Thread]