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’.


Reply via email to