lua-users home
lua-l archive

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


On Friday 04 February 2005 11:37, Andre Carregal wrote:
[...]
> 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.

You know, I don't care a whit about size or localisation issues (what is a 
whit, anyway?). But what I really do care about is flexibility and 
portability, and one huge problem with string-based error messages is that 
they're not well-defined enough to use properly as exceptions.

For example, if my C plugin runs out of memory, what's it supposed to do? 
Currently, it's supposed to do something like 'lua_error("out of memory")'. 
Unfortunately, this won't be caught be code that is expecting 
'lua_error("memory allocation failure")' or 'lua_error("malloc() returned 
NULL")'... the Lua core has a standard term for this, and a helper function 
to throw it, but it's not defined.

One of the great advantages of numeric error messages is, apart from 
localisation and internationalisation, that they're precise... if you get it 
right, it's completely right. You can't get it enough right that it looks 
like it works but not sufficiently right to work everywhere.

Even some helper tools that throw well-defined exception names would be great:

void lua_standarderror(int e)
{
 switch (e)
 {
  case LUA_ERROR_OUT_OF_MEMORY:
   lua_error("well-defined out-of-memory exception name");
  ...
 }
}

(Disclaimer: this post is made very late, and I'm not well and haven't had 
much sleep. Please excuse any tetchiness.)
 
-- 
David Given
dg@cowlark.com