question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Setting Scope for Evaluation

See original GitHub issue

Is it possible to set a scope containing all variables for evaluation? Something like this:

Map<String, BigDecimal> scope = new HashMap<>(); // contains values for a and b
scope.put("a", BigDecimal.ZERO);
scope.put("b", BigDecimal.ONE);
Expression ex = new Expression("a+b");
ex.eval(scope);

It would be nice if this wouldn’t mutate the internal state of ex, so the expression can be used across multiple threads.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:23

github_iconTop GitHub Comments

1reaction
RobertZenzcommented, Mar 6, 2018

Just to make it clear, I have no problem with you rejecting any of my changes (especially ones that I started working on without waiting for your reply first).

My thought behind this was that parsing the expression might be something expensive that one only wants to do once and then use that Expression instance to run on different values (even on different threads). That is my idea behind this, but I understand what you mean.

You are right, we could move all these properties into the Scope, but I wouldn’t have done that. It is unlikely that you want to evaluate the same expression with different precisions, but what one might like to do is evaluate it with different values. Reusing Expressions would also become a lot more explicit (because currently one can only overwrite already added variables) and that the Expression can be used over multiple threads with ease is a nice feature to have, in my opinion, that is why I wanted to do this at all.

0reactions
nikeeecommented, May 27, 2021

Thats what I felt like, too. So I developed a more or less replacement for EvalEx that covers our use-case. I can post it here when I’ve got some spare time.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setting the scope of an evaluation
In setting the scope of an evaluation, you need to consider the purpose, questions, criteria and standards.
Read more >
Scope of work | BetterEvaluation
A Scope of Work (SOW) is a plan for conducting an evaluation which outlines the work that is to be performed by the...
Read more >
How to Adjust a Rifle Scope in 2022 - Gun University
Adjusting the Scope Forward and Rearward​​ Only after your scope is at the right height, should you worry about the forward/rearward position. Get...
Read more >
How To Evaluate a Rifle Scope - OutdoorHub
A good scope has to provide predictable and consistent windage and elevation adjustments.
Read more >
Scope - AWS Config
Defines which resources trigger an evaluation for an AWS Config rule. The scope can include one or more resource types, a combination of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found