[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: The += operator, again
- From: Roberto Ierusalimschy <roberto@...>
- Date: Mon, 10 Dec 2018 10:19:36 -0200
> For a language like Lua I think a better solution to performant string
> construction would be something like Java's StringBuffer. This is trivial to
> do in Lua because the language emphasizes making use of the C API, and
> userdata objects are first-class in terms of language treatment. The real
> issue is that the Lua ecosystem isn't a batteries included kind of
> environment.
Many people (including me) use tables in place of string buffers. To add
an item to the buffer, we simply do 't[#t + 1] = item'. The expression
'table.concat(t)' produces the final string.
-- Roberto
- References:
- Re: The += operator, again, Domingo Alvarez Duarte
- Re: The += operator, again, David Favro
- Re: The += operator, again, Dirk Laurie
- Re: The += operator, again, Sven Olsen
- Re: The += operator, again, William Ahern