-
Notifications
You must be signed in to change notification settings - Fork 242
feature: Late Bind Function Calls at Evaluation Time #1172
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
base: master
Are you sure you want to change the base?
feature: Late Bind Function Calls at Evaluation Time #1172
Conversation
… UncheckedAstError() function
…ift latebinding to with flags
…hyp0th3rmi4/cel-go into featute/function-late-bind-eval
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Some considerations on existing limitations: Function FiltersAt present time we allow for all functions to be overloaded, maybe it would be a good idea to control the behaviour for operators that are implemented as function. The current code already avoids to manipulate Runtime Check for SignaturesThis capability is implemented in a rather limited number, which relies on matching the specific function overload configured in the evalXXX node with the function overload supplied at runtime (unary -> unary, binary -> binary, function -> function). This is good as a first implementation but very low level. We can address this issue by moving from
Alternativaly, in the |
Pull Requests Guidelines
This PR provides a minimal but fully functional prototype implementation for Late-binding functions at program evaluation time. It supports the discussion originated in: #1081, to demonstrate that it can be done.
The implementation comes fully tested in the new code that has been added, which has been kept at minimum, by trying to limit changes in the code base.
The model uses
functions.Overload
as the primary abstraction to supply run-time implementations of functions to replace the same overloads bound to the call nodes during tree parsing and checking.Files Changed:
interpreter/activation.go
: added a new interface LateBindActivation with ability to resolve overloads given an overload identifier.intepreter/decorators.go
: added the implementation of an InterpretableDecorator that manipulate call evalXXX nodes to defer the function bind at evaluation time.intepreter/interpreter.go
: added PlannerOption to inject latebind decorator.interpreter/late_binding.go
: implementation of the IntepretableCall nodes that perform late binding.cel/program.go
: integration of the creation fo the late binding planner option into the interpretable construction.cel/options.go
: definition of the late binding options to be supplied toProgram.Eval(....)
.Limitations:
This implementation is based on the
functions.Overload
and theinterpreter.Dispatcher
abstractions. As a result, runtime signature checks are very limited, but the additional burden is kept to minimum. This is because differently fromdecls.FunctionDecl
anddecls.OverloadDecl
,functions.Overload
does no longer maintain type information to perform any check.If an implementations based on the abstractions in the decls namespace is preferred, I can uplift the PR.