lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On 01/17/2012 05:08 PM, joao lobato wrote:

Also also, when you do need to use loadstring(), you should consider
using string.format() instead of all the string concatenation.

Lua handles string concatenation quite well. I long chain of `..' operations will just emit a series of register loads followed by a single CONCAT opcode.

On the other hand, string.format has the %q option which makes it safer for building strings that will be compiled. Perhaps this is what Joao was implying. Doing `code = "'" .. some_string .. "'"' invites arbitrary execution if some_string isn't properly protected.

- tom