[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Guile: What's wrong with this?
From: |
nalaginrut |
Subject: |
Re: Guile: What's wrong with this? |
Date: |
Wed, 04 Jan 2012 17:35:16 +0800 |
> > 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.
>
> Why not change the behavior 'define' to be (define y (substring str 0)) when
> STR
> is a read-only string? This would preserve the shared memory if the variable
> is never
> modified but still make the string copy-on-write.
>
> Regards,
>
> Mike
>
Hi guys! I just pass by and see your dispute.
I have been confused by the new immutable string design. But I used a
macro "make-mutable-string" which hide string-copy for an abstraction.
Anyway, if the efficiency would be an issue, one may choose bytevector
to implement "make-mutable-string". And it's easy to substitute with
sed.
BTW, can't we make an efficient "mutable-string" module for an
alternative? Just like old version. I mean it could be a Guile specific
feature.
--
GNU Powered it
GPL Protected it
GOD Blessed it
HFG - NalaGinrut
--hacker key--
v4sw7CUSMhw6ln6pr8OSFck4ma9u8MLSOFw3WDXGm7g/l8Li6e7t4TNGSb8AGORTDLMen6g6RASZOGCHPa28s1MIr4p-x
hackerkey.com
---end key---
- 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 <=
- Re: Guile: What's wrong with this?, David Kastrup, 2012/01/04
- 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