lua-users home
lua-l archive

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



On 01/11/2014 12:36, Enrico Colombini wrote:
> On 01/11/2014 11.39, Lorenzo Donati wrote:
>>> I think this is a bad idea in itself.  any message generated by the
>>> engine itself should be considered part of the implementation, not to
>>> be shown to a user.
>>
>> I strongly agree!
> 
> I think most of us agree on that. What I would like to have is a way to
> identify an error made by an user within a Lua-base domain-specific
> language, so that I could show an appropriate message
> (where "appropriate" could mean application-related, simplified and/or
> translated).
> 
> Currently the information available from pcall() and (indirectly) from
> xpcall() is the default "error object", which is a string.
> File name and line number are easily parsed from that string, error type
> and parameters are not.
> 
Yes, I agree that error management "overriding" is not easy in Lua.
Extracting information from errors coming from "lower level" layers of
an application is hard. It would be nice if the basic Lua error object
were a table populated with some useful fields and a __tostring
metamethod, so that one could say, for example, errobj.line,
errobj.message, etc., and still be able to print the error easily.


Alas, I fear that this would entail a radical overhaul of Lua codebase:
If I understood correctly what Roberto said, all errors are strings
built piecewise in different locations, with no "centralized" error
management or formatting routine.

Even if feasible, then there is the "fat penalty". How much fat could
Lua implementation take if the error building mechanisms were changed
like that? Maybe with Lua incorporating utf8 this would be an useful
addition and worth some "fat". Maybe it could even be a chance to
tidy things up? I don't know Lua codebase so well, but if error
generation is scattered throughout the code, maybe a reorganization of
the whole mechanism could even make Lua lose some weight. Really I don't
know.

I'm curious about what's the Lua team's mind about that.

Cheers!

-- Lorenzo

-- 
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments