lua-users home
lua-l archive

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


On Wed, Jan 14, 2015 at 3:49 PM, Tom N Harris <telliamed@whoopdedo.org> wrote:
> If library writers are eschewing throwing errors to not inconvenience users
> who aren't properly using pcall, then that contributes to the problem. Being
> more assertive (pun intended) will drag people kicking and screaming into
> proper defensive programming techniques.


I think you're elevating your preferences to "proper techniques".

I happen to prefer the nil,msg pattern for most cases, and to
explicitly use asert() when i want to signal errors.  pcall() (and, to
a lesser extent try/catch) are too similar to COMEFROM to my taste, so
i prefer to have only one, at most two levels of pcall() surrounding
most of the main loop or core/plugin interfaces, or so on.  i find
more readable to have error-handling code right there where the error
is reported (with the nil return)

-- 
Javier