Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate Func(Args) return value #27

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

maxlapshin
Copy link
Contributor

Need to validate return value from called function.

@rvirding
Copy link
Owner

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?

@maxlapshin
Copy link
Contributor Author

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.

@rvirding
Copy link
Owner

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?

@maxlapshin
Copy link
Contributor Author

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.

@rvirding rvirding force-pushed the develop branch 2 times, most recently from f4d581d to 192e2a0 Compare May 5, 2015 22:28
@rvirding rvirding force-pushed the develop branch 3 times, most recently from 4fdcb90 to c439c82 Compare February 26, 2022 20:58
@rvirding rvirding force-pushed the develop branch 2 times, most recently from 76b3c9b to 2124269 Compare January 28, 2024 01:14
davydog187 added a commit that referenced this pull request Oct 23, 2024
davydog187 added a commit that referenced this pull request Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants