starlight-go / starlight

a go wrapper for google's starlark embedded python language
MIT License
300 stars 29 forks source link

MakeStarFn: special handling for returning starlark.Value #17

Open yangzh opened 5 years ago

yangzh commented 5 years ago

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.