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

[RFC]: add support for eager evaluation of side-effect free code in the REPL #2073

Open
3 tasks done
kgryte opened this issue Mar 27, 2024 · 0 comments
Open
3 tasks done
Labels
difficulty: 4 Likely to be moderately difficult. Enhancement Issue or pull request for enhancing existing functionality. JavaScript Issue involves or relates to JavaScript. Needs Discussion Needs further discussion. priority: Normal Normal priority concern or feature request. REPL Issue or pull request specific to the project REPL. RFC Request for comments. Feature requests and proposed changes.

Comments

@kgryte
Copy link
Member

kgryte commented Mar 27, 2024

Description

This RFC proposes adding support for eager evaluation of side-effect free code in the REPL. E.g.,

In [1]: [ 'foo', 'bar', 'beep' ].sort()<|>
[ 'bar', 'beep', 'foo' ]

would trigger a preview below the input command, where <|> represents the cursor. Upon hitting ENTER, the command would execute with the result displayed after the output prompt, as normal.

This feature is now implemented in browser devtools, such as Chrome (see https://developer.chrome.com/blog/new-in-devtools-68/#eagerevaluation).

The tricky bit with implementing this is detecting side effects. And we'd likely want to avoid eagerly evaluating things like HTTP requests. Additionally, we'd like want to exclude things which are not idempotent (e.g., PRNGs, Date constructor, etc).

There is also the concern as to how to handle eager evaluation of computationally expensive commands or commands returning large outputs.

As this feature may not be desired by all users, we should presumably support an option for enabling/disabling this on REPL instantiation. And we should disable eager evaluation when not in TTY mode.

Related Issues

Questions

No.

Other

Resources:

Checklist

  • I have read and understood the Code of Conduct.
  • Searched for existing issues and pull requests.
  • The issue name begins with RFC:.
@kgryte kgryte added Enhancement Issue or pull request for enhancing existing functionality. RFC Request for comments. Feature requests and proposed changes. Needs Discussion Needs further discussion. REPL Issue or pull request specific to the project REPL. priority: Normal Normal priority concern or feature request. JavaScript Issue involves or relates to JavaScript. difficulty: 4 Likely to be moderately difficult. labels Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: 4 Likely to be moderately difficult. Enhancement Issue or pull request for enhancing existing functionality. JavaScript Issue involves or relates to JavaScript. Needs Discussion Needs further discussion. priority: Normal Normal priority concern or feature request. REPL Issue or pull request specific to the project REPL. RFC Request for comments. Feature requests and proposed changes.
Projects
None yet
Development

No branches or pull requests

1 participant