luerl
luerl copied to clipboard
Validate Func(Args) return value
Need to validate return value from called function.
I was wondering what would be the best way of handling bad return values. Instead of matching a pair would it be better to just accept anything as a bad return value and generate an error. Dou you intend and Erlang or a Lua error?
I think that erlang error is better, because problem is on erlang level.
And I don't understand why don't you like this patch. I check return value and if is bad, I raise error.
I don't dislike this patch, I was just wondering if it shouldn't be something like:
case Func(Args, St0#luerl{stk=Stk}) of
{Ret,St1} when is_list(Ret) ->
{Ret,St1#luerl{stk=Stk0}}; %Replace it
_ ->
error({invalid_reply,function,Func})
end;
so it catches all error returns?
so, maybe better:
case Func(Args, ...) of
{Ret, St1} when is_list(Ret) >
{Ret, St1#luerl{stk =Stk0}};
{Ret, St1} ->
error({invalid_reply,Ret,function,Func});
_ ->
error({invalid_return,function,Func})
end
?
On Jul 21, 2013, at 12:43 AM, Robert Virding wrote:
I don't dislike this patch, I was just wondering if it shouldn't be something like:
case Func(Args, St0#luerl{stk=Stk}) of {Ret,St1} when is_list(Ret) -> {Ret,St1#luerl{stk=Stk0}}; %Replace it _ -> error({invalid_reply,function,Func}) end; so it catches all error returns?
— Reply to this email directly or view it on GitHub.