objeck / objeck-lang

Objeck is a modern object-oriented programming language with functional features tailored for machine learning. It emphasizes expression, simplicity, portability, and scalability. The programming environment consists of a compiler, virtual machine, REPL shell, and command line debugger with IDE plugins.
https://objeck.org
Other
157 stars 11 forks source link

Mutable strings #476

Closed ghost closed 8 months ago

ghost commented 8 months ago

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.

objeck commented 8 months ago

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.

objeck commented 8 months ago

Deferred, seeking community due to time constraints.