-
-
Notifications
You must be signed in to change notification settings - Fork 544
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
Comments
@kgryte, we need to trigger the Is this the correct high-level idea? |
Or we need method which tell us weather the command is complete or not . cases like
and on the bases of this method we can go forward to process line and show the ghost output |
@MeastroZI as mentioned in the RFC, we should not be evaluating things which might trigger stuff like HTTP requests or any other stuff that can have side effects (ref). Hence, directly trying to execute the input is not the way. |
@Snehil-Shah so we need to check that weather the input is pure have no side effect , then after that we have to go further ? , And what about the context should we have to use the other context ? so it not pollute the global one as a side effect ? |
And have to implement something similar to the constantinople or to use it ? |
I think we would have to consider the global context. In devtools console, when you define a global variable, let's say a string. And in a later statement, you run a "pure" function on that string, it still eagerly evaluates. So, no, the context shouldn't be confined to that very input. I would suggest playing around with the chrome devtools console to get an idea of expected behavior. You might even find patterns that can help you understand the underlying implementation. |
@MeastroZI We would want to avoid additional dependencies. Maybe it can act as a reference literature for our implementation? And yes, we should execute the expression only after we are sure it has no side effects. |
I have researched a bit and play with the devtool and interested to go forward , i have one doubt that how can we find weather the function or method we have called from terminal is side effect free means , i have one way in my mind like this .
@Snehil-Shah and @kgryte can u tell me am i on correct path or not If not then i will greatly appreciate your guide |
@MeastroZI Can you explain better with some examples? Cases like mentioned in the OP and with global variables like:
|
sure
NOTE : in this case we require to maintain the local context as here we define the local variable and changing it
NOTE : in this case we need to context map need to be nested as there can be a variable define in like in this case this same example is impure
|
If i am in very wrong direction ! then please tell me , please don't just ignore me here. 😢 |
@MeastroZI you misunderstood my example
Plus also the examples in the RFC:
|
No i underdtood it and Completly agree with that to , but my question is how we can algorithmically we can define weather the method is side effect free or not ? Please refer this for completely understand my question. https://stackoverflow.com/questions/10662477/is-there-a-way-to-determine-if-a-javascript-function-has-side-effects# |
Specially if function is calling other funcrion and have nested call expression |
@MeastroZI I don't know (haven't dived into this yet), I'll leave that for you to figure out. |
As discussed during office hours today, the plan is to punt AST analysis for side effects to future work. Instead, at least for Before building such a database, the aim should be to implement the logic and UX for displaying result previews. As a test case, the implementation should assume that a single API (e.g., |
Description
This RFC proposes adding support for eager evaluation of side-effect free code in the REPL. E.g.,
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
RFC:
.The text was updated successfully, but these errors were encountered: