One of the slow parts about Copper is string handling within Copper itself. In trying to use Copper for handling strings from files, you may discover there is no object type for handling lists of characters. This is different from strings because lists can grow and strings cannot. Thus, the preferred approach is to create a list containing strings of single characters, and this way the list can grow and shrink and be modified. However, it does bring up the problem: How do we get the list back into being a string? After all, it would be annoying to create loops everywhere (e.g. for printing) just to iterate through all the characters.
I decided to create a simple extension function, not part of the engine but one you will definitely want if you work with strings. It’s called StringListConcat, and in Copper, it is str_list_concat(). The function accepts both strings and lists of strings and combines them into a single string as efficiently as feasible on the C++ side.
Simple example:

a = list("Hello" “World”)
print( str_list_concat(a: “Dog") )

Output: HelloWorldDog


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s