[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: override assignment operator (Dirk Laurie)
- From: joao lobato <btnfdp.lobato@...>
- Date: Thu, 19 Jan 2012 12:19:20 +0000
On 1/18/12, Tom N Harris <telliamed@whoopdedo.org> wrote:
> 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
> telliamed@whoopdedo.org
>
>
You give me more credit than you should :-), I meant for performance
reasons, guess I was wrong.
However, imho, string.format is much more readable (no need to quote
quotation marks, easier to indent, the %s and %q stand out...)