lua-users home
lua-l archive

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


On 21 September 2014 08:10, Andrew Starks <andrew.starks@trms.com> wrote:

Because most times, there is nothing that you can do. In the last example if there were no "EAGAIN", then there would have been no "pcall" and no "if then". Even if there is something for you to do, it's only in one spot that you do it and it's not uncommon for that spot to be further up the stack. If you "nil, err", you have to "if then" back to the caller that cares. 

Likewise, you must do this every time that you might get "nil, err" because if you forget, then you have a potentially tricky bug to find. With pcall, if you forget, you have an angry user or developer and an extremely easy to spot fix for it. [1]

-Andrew

[1] whenever I rant like this, I think about what I'm missing. I think that it's possible that error issues become trickier when things are IO and thread heavy and when they're not separated correctly. The possibility has me worried for my own code. :)

This is why I was pointing out Luerl, which is Lua on top of erlang, as erlang is very good at handling these situations. In fact it was designed for it. And you can write client code in Lua.

Robert