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

runtime.Call keeps running continuations #97

Open
TheCount opened this issue Feb 2, 2023 · 0 comments
Open

runtime.Call keeps running continuations #97

TheCount opened this issue Feb 2, 2023 · 0 comments

Comments

@TheCount
Copy link
Contributor

TheCount commented Feb 2, 2023

The doc for runtime.Call says:

func Call(t *Thread, f Value, args []Value, next Cont) error
Call calls f with arguments args, pushing the results on next. It may use the metamethod '__call' if f is not callable.

Actually, Call not only pushes the results of the call to f onto next, but proceeds running next and further continuations until nil or an error occurs.

I'm guessing this is the intended behavior, but I think that with this documentation and/or the name Call, this API is confusing, especially if seen in contrast to runtime.Call1, which has a more "expected" signature:

func Call1(t *Thread, f Value, args ...Value) (Value, error)

One possibility to make the API more intuitive would be to rename Call to something else (e. g. TailCall) and add a new Call API

func Call(t *Thread, f Value, args []Value, ret []Value) error

whose implementation would call the "old" Call with a termination for next.

What do you think?

TheCount added a commit to TheCount/golua-proto that referenced this issue Feb 2, 2023
rt.Call already runs the continuation, see
arnodel/golua#97
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

No branches or pull requests

1 participant