ANN: StringBuilders.jl

I was thinking about a mutable AbstractString type along the lines of uio.h: struct iovec. It would be like a lazy string builder. Rather than allocating new strings, it would just keep a list of the strings that were appended. A new concatenated string would be created by doing convert(String, ...). Or, if the string was written to an IO stream, the new string would never need to be created. The write function could just write each collected item in turn.

(My use case is splicing changes into JSON texts)

struct SplicedString
    v::Vector{AbstractString}
end

append! just adds to the list:

append!(s::SplicedString, x::AbstractString) = push!(s.v, x)

splice-ing a String creates a SplicedString using SubStrings of the original string:

splice(s::AbstractString, i, x::AbstractString) =
    SplicedString([SubString(s, 1, i), x, SubString(s, i+1)])

splice! would figure out which item in s.v contains index i, then splice x into that item:

splice!(s::SplicedString, i, x) = ...
write(io::IO, s::SplicedString) = write(io, s.v...)