develooper Front page | perl.perl6.internals | Postings from July 2002

Re: Mutable vs immutable strings

Thread Previous | Thread Next
Florian Haeglsperger
July 10, 2002 07:07
Re: Mutable vs immutable strings
Message ID:
I'm following this list only for a very short time now, and I don't have very much
programming experience, so tell me if all this is pure nonsense.

But isn't this partly addressed with COW? The way I understood Copy On Write, it means
that if you "copy" a string, only some pointers are copied and some flags are set, until you
modify one of the two strings. So IMHO, this shouldn't be too much slower than simply
copying the pointer of an immutable string.
And if you wanted to change a mutable string buffer (which has been passed to your code
by reference, for example), you might want to make a copy anyway, which is exactly what
happens when you modify a "copied" string in Parrot.
Thus I don't see a very big performance win in introducing mutable strings.

Am 10.07.2002 14:00:16 schrieb John Porter <>:

>"Clark C . Evans" wrote:
>> So, I propose that Parrot supports both of these attitudes
>> of reasoning by using a flag.   Initially, all strings
>> are 'mutable'.
>I concur with Clark.  What he's proposing is (it seems to me)
>nothing more than a "read-only" flag, and that's as 
>immutable as a variable needs to get.
>However, I'm concerned about the performance impact of such a thing.
>Perhaps a better approach would be to swap out the mutator methods
>with code that throws.
>John Douglas Porter
>Do You Yahoo!?
>Sign up for SBC Yahoo! Dial - First Month Free

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About