[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Guile: What's wrong with this?
From: |
David Kastrup |
Subject: |
Re: Guile: What's wrong with this? |
Date: |
Wed, 04 Jan 2012 10:41:33 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) |
Mike Gran <address@hidden> writes:
>> In many systems it is desirable for constants (i.e. the values of literal
>> expressions) to reside in read-only-memory. To express this, it is
>> convenient to imagine that every object that denotes locations is
>> associated with a flag telling whether that object is mutable or immutable.
>> In such systems literal constants and the strings returned by
>> `symbol->string' are immutable objects, while all objects created by
>> the other procedures listed in this report are mutable. It is an error
>> to attempt to store a new value into a location that is denoted by an
>> immutable object.
>>
>> In Guile this has been the case since commit
>> 190d4b0d93599e5b58e773dc6375054c3a6e3dbf.
>>
>> The reason for this is that Guile’s compiler tries hard to avoid
>> duplicating constants in the output bytecode. Thus, modifying a
>> constant would actually change all other occurrences of that constant in
>> the code, making it a non-constant. ;-)
>
> This is a terrible example of the RnRS promoting some strange idea of
> mathematical purity over being useful.
>
> The idea that the correct way to initialize a string is
> (define x (string-copy "string")) is awkward. "string" is a read-only
> but copying it makes it modifyiable? Copying implies mutability?
>
> Copying doesn't imply modifying mutability in any other data type.
Huh?
(set-car! '(4 5) 3) => bad
(set-car! (list-copy '(4 5)) 3) => ok
Similar with literal vectors.
Why should strings be different here?
--
David Kastrup
- Re: The empty string and other empty strings, (continued)
- Re: Guile BUG: What's wrong with this?, Bruce Korb, 2012/01/06
- Re: Guile: What's wrong with this?, Ian Price, 2012/01/07
- Re: Guile: What's wrong with this?, Mark H Weaver, 2012/01/08
- Re: Guile: What's wrong with this?, David Kastrup, 2012/01/06
- Re: Guile: What's wrong with this?, David Kastrup, 2012/01/05
- Re: Guile: What's wrong with this?, Ludovic Courtès, 2012/01/04
- Re: Guile: What's wrong with this?, Mike Gran, 2012/01/03
- Re: Guile: What's wrong with this?, nalaginrut, 2012/01/04
- Re: Guile: What's wrong with this?,
David Kastrup <=
- Re: Guile: What's wrong with this?, Ludovic Courtès, 2012/01/04
- Re: Guile: What's wrong with this?, Mark H Weaver, 2012/01/04
- Re: Guile: What's wrong with this?, Mike Gran, 2012/01/04
- Re: Guile: What's wrong with this?, David Kastrup, 2012/01/04
- Re: Guile: What's wrong with this?, Andy Wingo, 2012/01/04
- Re: Guile: What's wrong with this?, David Kastrup, 2012/01/04
- Re: Guile: What's wrong with this?, Andy Wingo, 2012/01/04
- Re: Guile: What's wrong with this?, David Kastrup, 2012/01/04
- Re: Guile: What's wrong with this?, Andy Wingo, 2012/01/04
- Re: Guile: What's wrong with this?, Bruce Korb, 2012/01/04