* substring
@ 2012-09-07 17:49 .
2012-09-07 18:05 ` substring Mike Gran
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: . @ 2012-09-07 17:49 UTC (permalink / raw)
To: guile-user
Hi,
Why do we need substring [1]? We already have string-copy which looks
similar to me.
(These functions take different number of arguments, but string-copy
can handle this because it's more generic.)
Is this connected with compatability, convenience or something else?
[1] http://www.gnu.org/software/guile/manual/html_node/String-Selection.html#String-Selection
Thanks
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: substring
2012-09-07 17:49 substring .
@ 2012-09-07 18:05 ` Mike Gran
2012-09-07 19:34 ` substring Ian Price
2012-09-08 2:00 ` substring nalaginrut
2 siblings, 0 replies; 5+ messages in thread
From: Mike Gran @ 2012-09-07 18:05 UTC (permalink / raw)
To: ., guile-user@gnu.org
>
>Hi,
>
>Why do we need substring [1]? We already have string-copy which looks
>similar to me.
>(These functions take different number of arguments, but string-copy
>can handle this because it's more generic.)
I haven't looked at the code lately, but, it used to be that substring
would allow you to create a string that initially shared the same string
buffer as the string from which it was derived, saving memory. Later, if
you tried to modify the substring or the parent string, it would
allocate a new string buffer for itself. But if you never modified the parent
or the substring, they would always point to (presumably different)
locations in the same string buffer.
-Mike
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: substring
2012-09-07 17:49 substring .
2012-09-07 18:05 ` substring Mike Gran
@ 2012-09-07 19:34 ` Ian Price
2012-09-08 2:00 ` substring nalaginrut
2 siblings, 0 replies; 5+ messages in thread
From: Ian Price @ 2012-09-07 19:34 UTC (permalink / raw)
To: .; +Cc: guile-user
"." <nkwerk@gmail.com> writes:
> Hi,
>
> Why do we need substring [1]? We already have string-copy which looks
> similar to me.
> (These functions take different number of arguments, but string-copy
> can handle this because it's more generic.)
>
> Is this connected with compatability, convenience or something else?
substring is in the standard, has been for ages.
--
Ian Price -- shift-reset.com
"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: substring
2012-09-07 17:49 substring .
2012-09-07 18:05 ` substring Mike Gran
2012-09-07 19:34 ` substring Ian Price
@ 2012-09-08 2:00 ` nalaginrut
2012-09-09 22:19 ` substring Ludovic Courtès
2 siblings, 1 reply; 5+ messages in thread
From: nalaginrut @ 2012-09-08 2:00 UTC (permalink / raw)
To: .; +Cc: guile-user
On Fri, 2012-09-07 at 21:49 +0400, . wrote:
> Hi,
>
> Why do we need substring [1]? We already have string-copy which looks
> similar to me.
> (These functions take different number of arguments, but string-copy
> can handle this because it's more generic.)
>
> Is this connected with compatability, convenience or something else?
>
> [1] http://www.gnu.org/software/guile/manual/html_node/String-Selection.html#String-Selection
>
*string-copy is actually substring/copy, which is a newly allocated
string buffer.
*substring is a copy-on-write version.
*substring/shared is actually the same string buffer with the original
string. It won't do any copy operation.
> Thanks
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: substring
2012-09-08 2:00 ` substring nalaginrut
@ 2012-09-09 22:19 ` Ludovic Courtès
0 siblings, 0 replies; 5+ messages in thread
From: Ludovic Courtès @ 2012-09-09 22:19 UTC (permalink / raw)
To: guile-user
Hi,
nalaginrut <nalaginrut@gmail.com> skribis:
> *string-copy is actually substring/copy, which is a newly allocated
> string buffer.
>
> *substring is a copy-on-write version.
And these two procedures live at a different abstraction level: the name
‘string-copy’ suggests memory management, whereas ‘substring’ suggests
an operation on a string (which happens to use COW, but that’s an
implementation detail.)
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-09-09 22:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-07 17:49 substring .
2012-09-07 18:05 ` substring Mike Gran
2012-09-07 19:34 ` substring Ian Price
2012-09-08 2:00 ` substring nalaginrut
2012-09-09 22:19 ` substring Ludovic Courtès
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).