lua-users home
lua-l archive

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

On 27/09/2013 17.50, Rena wrote:
To determine the actual error now requires some string parsing which is a
bit inefficient.

I've given some thought to this matter in the past (definitely not as much as you did) and one of the ideas for a compatible solution was to prepend error strings with an unique numeric code, e.g.:

  [1234] stdin:1: attempt to index global 'a' (a nil value)

Far from ideal, and that's the reason why I didn't propose it, but at least the error code could be read with a simple pattern match.
(yes, I know, I can always patch the source)

Actually, what started me thinking about it was a need for error message localization, or 'translation' (not in a linguistic sense) for non-professional users of Lua-based DSLs. If Lua used an error code, or (probably better, but non backward-compatible) an error object as index in a message table, it would be easier to switch language and/or customize error messages without messing with the source code.

Just old, sparse, incoherent thoughts.