lua-users home
lua-l archive

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


On 07/05/2020 15:51, Luiz Henrique de Figueiredo wrote:
I wonder why you decided not to let a program to set its own "warning"
handler from Lua, but only from C API.

We can already intercept somewhat the error handling routines with
xpcall, why not allow customizing warning handling from Lua too?

A warning is not an error condition. Your Lua program behaves the same
with or without a warning.

Yep, I get that. I just wanted to know why you chose not to let the Lua programmer customize the behavior of the "warning handler".

In other words, why can I generate a warning from Lua but cannot customize how it is handled?

It seems that only half of the mechanism is exposed to Lua programmers, and I can't understand why. If it is too low level a mechanism (only reserved to C API users), why expose the `warn` function at all?

OTOH, if warnings are meant to be useful in a general Lua program, why can't a programmer customize how they are handled. After all, the default warning function just prints the warning to the terminal, which is a pretty limited use case. A programmer could well think of logging warnings messages to a file or send them to a remote system via some protocol.

Probably I'm missing something, but I can't understand the usefulness of `warn` alone in a pure Lua program without the ability to choose how to handle the warnings. What's the point of `warn` (with the default warning function), if it is just a different way to perform a write to stderr (or stdout, I didn't check which stream is actuall used)?


_______________________________________________
lua-l mailing list -- lua-l@lists.lua.org
To unsubscribe send an email to lua-l-leave@lists.lua.org

_______________________________________________
lua-l mailing list -- lua-l@lists.lua.org
To unsubscribe send an email to lua-l-leave@lists.lua.org