Tag: strings

ConcatListOfStrings

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

Progress Report #10 – Filling in Gaps

New changes this week in Copper fill in some of the gaps that show up when trying to use Copper for real-world projects. The first of these is the indication of the support of multiple interfaces, which solves the dilemma of distinguishing between polymorphic objects turned into Copper objects. The second is the addition of a system function that enables the sharing of user-created function bodies.

In other notes, the string_map extension received a bug fix for not correctly returning when “exit” was called in the middle of the callback function it was given.

Continue reading “Progress Report #10 – Filling in Gaps”