[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: rfi: immutable strings
From: |
Ludovic Courtès |
Subject: |
Re: rfi: immutable strings |
Date: |
Sat, 08 Jan 2011 22:57:00 +0100 |
User-agent: |
Gnus/5.110011 (No Gnus v0.11) Emacs/23.2 (gnu/linux) |
Hi!
>> Guile needs immutable strings. String literals should be immutable, so
>> that its characters can come directly from objcode. Also, the result of
>> (symbol->string 'foo) should be immutable; currently symbol->string
>> conses up a new shared substring every time.
>
> How is this different from read-only strings?
Indeed, statically allocated stringbufs are immutable, for instance (see
‘SCM_IMMUTABLE_STRING’ in ‘snarf.h’.)
Read-only strings are also used elsewhere:
--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> (string-set! (symbol->string 'foo) 2 #\x)
ERROR: In procedure string-set!:
ERROR: string is read-only: "foo"
--8<---------------cut here---------------end--------------->8---
Thanks,
Ludo’.