Skip to content

runtime.Call keeps running continuations #97

Description

@TheCount

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions