* Re: rfi: immutable strings
@ 2011-01-07 18:52 Mike Gran
2011-01-08 21:57 ` Ludovic Courtès
2011-01-27 16:31 ` Andy Wingo
0 siblings, 2 replies; 4+ messages in thread
From: Mike Gran @ 2011-01-07 18:52 UTC (permalink / raw)
To: Andy Wingo, guile-devel
> Hello,
>
> 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?
(BTW, you guys are doing some cool stuff right now. I wish I could dig in,
but I'll be AWOL for a few more weeks trying to get updates of my other
projects out the door.)
-Mike
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: rfi: immutable strings
2011-01-07 18:52 rfi: immutable strings Mike Gran
@ 2011-01-08 21:57 ` Ludovic Courtès
2011-01-27 16:31 ` Andy Wingo
1 sibling, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2011-01-08 21:57 UTC (permalink / raw)
To: guile-devel
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’.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: rfi: immutable strings
2011-01-07 18:52 rfi: immutable strings Mike Gran
2011-01-08 21:57 ` Ludovic Courtès
@ 2011-01-27 16:31 ` Andy Wingo
1 sibling, 0 replies; 4+ messages in thread
From: Andy Wingo @ 2011-01-27 16:31 UTC (permalink / raw)
To: Mike Gran; +Cc: guile-devel
On Fri 07 Jan 2011 19:52, Mike Gran <spk121@yahoo.com> writes:
>> Guile needs immutable strings.
>
> How is this different from read-only strings?
Seems to be the same. We should have read-only string API though;
currently there is only substring API. One should be able to allocate a
read-only string directly, like via
scm_from_static_latin1_{stringn,symboln}. Also, strings loaded from
objcode should be read-only, and share storage with the objcode itself;
perhaps?
>> Also, the result of (symbol->string 'foo) should be immutable;
>> currently symbol->string conses up a new shared substring every time.
Though the result is immutable, it does cons up a shared substring,
which involves all kinds of mutex and allocation shenanigans.
Andy
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* rfi: immutable strings
@ 2011-01-07 16:57 Andy Wingo
0 siblings, 0 replies; 4+ messages in thread
From: Andy Wingo @ 2011-01-07 16:57 UTC (permalink / raw)
To: guile-devel
Hello,
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.
In practice this means a flag on the stringbuf.
Takers? :)
Andy
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-01-27 16:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-07 18:52 rfi: immutable strings Mike Gran
2011-01-08 21:57 ` Ludovic Courtès
2011-01-27 16:31 ` Andy Wingo
-- strict thread matches above, loose matches on Subject: below --
2011-01-07 16:57 Andy Wingo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).