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

eval is evil (and undocumented) #1950

Closed
benjie opened this issue Feb 8, 2024 · 7 comments
Closed

eval is evil (and undocumented) #1950

benjie opened this issue Feb 8, 2024 · 7 comments
Assignees

Comments

@benjie
Copy link
Member

benjie commented Feb 8, 2024

Ref: https://discord.com/channels/489127045289476126/498852330754801666/1205068909787746304

So apparently the eval methods are completely undocumented... Good to know.

Yes; all the eval methods have a cost, but the more specific you can be the better. .evalHas(key) causes the plan to branch such that .evalHas('foo') will have two versions of the plan - one where foo is present, and one where foo is not present. (Compare to .eval() where each individual different object will result in a new plan.)

$__inputStep.evalHas(key): two plans
$__inputStep.eval(): almost infinite plans
$__inputStep.evalLength(): one plan for each length of the list
$__inputStep.evalIs(val): two plans (one where $__inputStep's value === val; and one where it doesn't)

@github-project-automation github-project-automation bot moved this to 🌳 Triage in V5.0.0 Feb 8, 2024
@benjie benjie moved this from 🌳 Triage to 🐭 Shrew in V5.0.0 Feb 8, 2024
@benjie
Copy link
Member Author

benjie commented Feb 8, 2024

@jemgillam I think details of this was in one of the sponsors only talks; perhaps you could extract it and add to the docs?

@benjie
Copy link
Member Author

benjie commented May 10, 2024

Actually, we're looking to maybe remove eval if we can... So let's put this on ice.

@jemgillam
Copy link
Contributor

jemgillam commented Oct 4, 2024

how does tamedeval relate to eval() ?
A better question is, can one use tamedeval in place of eval() in Version 5?

tamedeval doesn't solve the problem of multiple plans being generated.

@benjie
Copy link
Member Author

benjie commented Oct 4, 2024

eval() in JS evaluates a string as code.

tamedevil makes it easier to work with eval() in a safe way.

In Grafast, input steps have an .eval() (or .evalIs(), .evalHas(), etc) method. This is unrelated to JS's eval() and thus to tamedevil; it only relates to evaluating the real value of this step during planning (and means that the plan is only valid for future requests where the evaluated value or expression matches).

@jemgillam
Copy link
Contributor

jemgillam commented Oct 7, 2024

@jemgillam I think details of this was in one of the sponsors only talks; perhaps you could extract it and add to the docs?

Hmmm I think I don't have access to those videos, I guess it was a Discord event?

Is discussed in June '24 working group: https://youtu.be/dqfyhM0sjoE?si=d5-t5xvqC75PZ_f_&t=1483 but that's not what you're referring to above

@benjie
Copy link
Member Author

benjie commented Oct 7, 2024

@jemgillam
Copy link
Contributor

Closed with #2213

@github-project-automation github-project-automation bot moved this from 📝 Docs Improvements to ✅ Done in V5.0.0 Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

2 participants