[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Another alternative string representation proposal
From: |
Dirk Herrmann |
Subject: |
Re: Another alternative string representation proposal |
Date: |
Tue, 26 Sep 2000 11:20:03 +0200 (MEST) |
address@hidden (Carl R. Witty) writes:
> > Is owner_p really necessary? If a char-field is read-only, it is not
> > the owner of the character sequence. If it is mutable or immutable,
> > we can force the char-field to own the sequence.
>
> I can see at least one potential use for a mutable, not-owned string:
> it could be used by a guile wrapper for mmap. Although probably it
> would be better to use a different, specialized type for this; so
> that's not much of an argument...
I'd like to give another example for a case, where mutable, not-owned strings
make sense. Assume the following function f, which takes an already existing
string, but initializes or overwrites it with something.
void
f (SCM aString, unsigned int n)
{
/* Fill the first n characters of aString with something. */
}
A possible use of function f might be to initialize a temporary string:
void
g ()
{
char tmp_chars[4];
SCM tmp_string = scm_make_mutable_not_owned_string (tmp_chars, 4);
gh_display (f (tmp_string, 4));
}
It's obvious that this gives much better performance than having to allocate
a small memory region just to have a mutable string.
Still, I don't want to claim that we really need mutable strings, but we
should be aware of potential uses before we come to a decision about them.
Best regards
Dirk