Skip to content
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 method access on non-structs #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

palmdalian
Copy link

I was trying to do an expression with a uuid .String() method, but reflect shows that as an array instead of struct.

All of the tests pass and my use case seems to work now...so I think we're good?

@palmdalian
Copy link
Author

Hello,

Have you seen https://github.com/antonmedv/expr? 😃

@antonmedv I hadn't! Nice project. The reason why we forked govaluate is that we needed two use cases:

  1. To reduce expressions using the environment map and leave variables in place that aren't in that map.
  2. Output and translate that reduced expression back out to a string that we send to the client for them to evaluate on device with a java library (https://github.com/uklimaschewski/EvalEx)

I didn't see that as an option for your library, but the Reduce function is pretty nice if you're looking for new features to add 😃

@antonmedv
Copy link

Can you tell me more about this reduce function more? 😀

@palmdalian
Copy link
Author

Can you tell me more about this reduce function more? 😀

Sure! You can see the tests should give a decent idea: https://github.com/tonalfitness/govaluate/blob/master/reduce_test.go
The basic idea is that you pass in a set of known values and it does variable replacement or partial evaluation of any nodes that can be simplified.

The other part is Print.go that lets you override literals to conform with other libraries.
https://github.com/tonalfitness/govaluate/blob/master/print_test.go
Not sure if that case is as common, but govaluate had something similar for outputting as as sql string.

@antonmedv
Copy link

Expr has something similar to reduce: constant folding
But this functionality unexported and used during compile step.

Print to SQL not supported, yeah.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants