starlight icon indicating copy to clipboard operation
starlight copied to clipboard

MakeStarFn: special handling for returning starlark.Value

Open yangzh opened this issue 6 years ago • 0 comments

First of all, great code and I'm enjoying it!

Not sure if my complain makes sense or any of you are aware of this, but when I tried to use convert.MakeStarFn to construct a *starlark.Builtin object, I will use a user function that will return a Starlark.Value, and convert.MakeStarFn code will put another wrapper about that, which is not good.

To give a concrete example, here is snippet of my code:

fnSomeCtor = covert.MakeStarFn("constructor", func(foo int) (starlark.Value, error) { // return my own object that implements starlark.Value })

currently convert.toValue() doesn't let a starlark.Value to pass through unharmed, instead, I think the code wraps it into a GoInterface(?), which is not good, as the consumer (my part) will get confused.

Can you special-case for starlark.Value? thanks.

yangzh avatar May 14 '19 00:05 yangzh