lua-users home
lua-l archive

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


On Fri, Jan 23, 2009 at 2:23 PM, Kristofer Karlsson <kristofer.karlsson@gmail.com> wrote:
I disagree, I think it's a bug.
Bugs aren't just about getting valid output for valid inputs, it's also about giving clear and understandable errors whenever possible.
string.format throws an error if it encounters an unterminated "%", so it only makes sense that gsub should too.
Silently ignoring the error and doing something completely different is nog very friendly behaviour.

> = string.format("%")
stdin:1: invalid option '%' to 'format' 

Thanks everyone for the information. My mistake. But I agree with Kristofer, it would have been much better to have this. In my case it was user input that lead me to this, I didn't remember I would have to filter it first before using it with an string.gsub(). So, it would be much nicer to have the error message instead of the undefined behavior.

Best,
Daniel