-
Notifications
You must be signed in to change notification settings - Fork 50
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
Accessing ParametersSpec from a DefGen in a native function #17
Comments
The idea of the function is that it is currently opaque - you can invoke it, but there's no way to get the and give it arguments, but you can't inspect what arguments it requires or what its name is. To change that we'd need to:
What's the reason for wanting to understand the function arguments passed to a native function? |
I'm seeing if it is feasible to use For example, a developer would pass a method to a native Rust function in that's exposed to Starklark, which would get evaluated when a particular event happens at a later time: def handle_message(title, body):
if title == "error":
native.send_email("webmaster@example.com", body)
native.on_message(func=handle_message) This program would get evaluated and a reference to the callbacks to I was toying with the idea of inspecting the parameters specified on the method to match the incoming event to parameter names to make it a bit easier to use. There are various other ways this could be achieved. For instance by evaluating the program for each message and use the |
As I sat down to look at this again today I realize I can get pretty far by introducing a level of indirection in starlark and use Thanks for the library. I don't have a need to expose function details directly Rust integrators right now. Until that changes I'll go ahead and close this ticket. |
Glad you've figured out a way. Note that you might want to update the code if you still have Context - the latest code has moved to use Evaluator as the name. As part of the preparation for a release (which we're planning tomorrow) we've renamed a bunch of names that hadn't been considered since the initial fork. Following our release tomorrow we expect things to be pretty stable. There is also the function |
I'm trying to access the static components of a
ParametersSpec
from a native method exposed to the Starlark evaluator when the input into the method is a method. Example:The
Value
received is a struct of typeDefGen
which is private ineval
:Is there an approach to get access to the
ParametersSpec
for the passed in function that I am missing or another potential way to read it? If not, is that something that might be worth adding?The text was updated successfully, but these errors were encountered: