lua-users home
lua-l archive

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


On Fri, 04 Feb 2005 10:33:50 GMT, "Andy Stark" <astark@blackpoolsixth.ac.uk> escreveu:
[...]
> But while we are looking at error messages, it would also be a good idea
> to take the error strings from the C source files and put them into their
> own header file called "lerrmsg.h". They would be kept in numerical order
> in this file and referenced by macros. So the file would look something
> like:-
> 
> /* Double-digit numbers recommended! */
> #define LERR01 "stack overflow (#01)"
> #define LERR02 "cannot yield a C function (#02)"
[...]
> All this just seems to me to be a very simple way to make Lua slightly
> more attractive to embedders, beginning programmers and people who don't
> read English very well.

I don't know the impact of this separation on size/speed of Lua, but I agree that l10n and i18n would be a lot easier this way. On the other hand, I believe most users would still shudder at the (#01) part.

Would it be feasible to improve those macros and allow for two modes of operation that would optionally concatenate the (#nn) part? This concatanation should be done by the macro of course.

This way one could choose before compiling Lua if the messages would present or not the numbered part, and the manual (or just a page on the site) could present them in numerical order.

Even fancier macros could allow a third mode that uses only the numeric part... for example:

#define LERR_PRE "(#"
#define LERR_POS ")"

#define LERR01_TEXT = "stack overflow"
#define LERR01_CODE = "01"
...

#define LUA_MSG (code) = ...

Is it possible to use code as a part of a macro name? If so, the LUA_MSG macro would receive code as a parameter and depending on the message mode would result in one of

LERR(code)_TEXT
LERR(code)_TEXT LERR_PRE LERR(code)_CODE LERR_POS
LERR(code)_CODE

I'm afraid this is not C, that's why I'm asking if it is doable by macros... :o)

Andre Carregal