-
-
Notifications
You must be signed in to change notification settings - Fork 422
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
Allow to use operator tokens as functions #577
Allow to use operator tokens as functions #577
Conversation
Lets just allow to use "endsWith" |
…With, matches, in)
I have made the necessary updates based on your feedback. |
This function is very important for my code, could you please add this function to the latest version with a tag, so that I can add it to the code |
Let's try to implement this feature without adding additional options. I will try to do it. |
I have removed option functionality from configuration as per your feedback |
Awesome work! |
I actually not understand what original issues is was about: #568 Is to be able to use reuse operator names as functions: options := []expr.Option{
expr.Function(
"contains",
func(params ...any) (any, error) {
return false, nil
},
new(func() bool),
),
}
program, err := expr.Compile(`contains()`, options...) I think this is a bad practice and not should be allowed. Also I think it's bad decision to allow to use some operators as functions =/ Let's not processed this this PR @ckganesan? |
operator becomes a function to increase the extensibility, convenient for users to customize or extend. Consider a scenario where the user needs to pass in multiple arguments to the contains function, and the original operator is not satisfied, we can extend it to contain from an operator to a function |
Can you show some examples? |
Because I think this allows the user to customize a higher degree, the experience will be better |
Will this operation be allowed |
No. For now, not. I don't see a use case. And adding such feature complicates parser and type checker. |
This PR enables the usage of operator tokens as functions. #572