lua-users home
lua-l archive

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


On 09/19/2014 06:52 PM, Andrew Starks wrote:
First, I appreciate anyone and everyone that is sticking with me on
this. I hope that I do not sound argumentative. The responses thus far
are helpful.

Just in case, I must say I find these kind of threads wildly interesting :)


Your example is essentially how I do everything now. Here is the pcall
variant, for comparison:

I think the conceptual difference is that the ret,err scheme assumes you care more for the result, and only then for details on errors, and in the pcall is the other way: you first want to know if there was an error, then take care of the return.

Another con of pcall based APIs is that it looks like boilerplate code: if I am supposed to always do some magic incantation for invoking the library under the risk of crashing everything, then why the library doesn't do it itself for me :)

Jorge