stdlib-js / stdlib-js/stdlib

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

オープン
#2,073 コメント 22 件 リアクション 0 件 担当者 0 名 GitHub で見る
difficulty: 4 Enhancement JavaScript Needs Discussion priority: Normal REPL RFC
主要言語
JavaScript
スター
6k
フォーク
1.3k
平均マージ
1日 3時間
マージ済み PR(30日)
611

説明

### 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

- object completion: https://github.com/stdlib-js/stdlib/issues/1794

### Questions

No.

### Other

Resources:

- https://developer.chrome.com/blog/new-in-devtools-68/#eagerevaluation
- https://github.com/pugjs/constantinople/tree/master

### Checklist

- [X] I have read and understood the [Code of Conduct](https://github.com/stdlib-js/stdlib/blob/develop/CODE_OF_CONDUCT.md).
- [X] Searched for existing issues and pull requests.
- [X] The issue name begins with `RFC:`.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。