objeck/objeck-lang

Mutable strings

Closed this issue · 2 comments

If you don't want to add a new string class like StringBuilder, what about extending the existing String class?

For example:

Normal immutable string: "A test string"

Mutable string: @"A test string", or $"A test string" if you decided to use @ for verbatim strings.

Something like @"A test string"->Replace("test", "sample"); will be able to modify the string.

In Objeck, string literals are immutable and pooled. A programmer can modify a string instance but not a literal. The String class tries to reduce object allocation when possible. For example, appending or inserting characters into a String instance should not create a new instance.

Writing and testing a new string class is an effort. If you would like to start the implementation I will assist as needed.

Deferred, seeking community due to time constraints.