elm-lang / elm-repl

A REPL for Elm
BSD 3-Clause "New" or "Revised" License
170 stars 34 forks source link

With a huge nested tuple in scope, all expressions take 30 seconds to complete #160

Open endlessoblivion opened 7 years ago

endlessoblivion commented 7 years ago

After defining a sequence of functions like:

nest = (,,,,,,,,)
n0 = nest
n1 = nest n0 n0 n0 n0 n0 n0 n0 n0 n0 -- sorry, I didn't find a way
n2 = nest n1 n1 n1 n1 n1 n1 n1 n1 n1 -- how to do it via recursion
n3 = nest n2 n2 n2 n2 n2 n2 n2 n2 n2 -- or by spreading a list
n4 = nest n3 n3 n3 n3 n3 n3 n3 n3 n3
n5 = nest n4 n4 n4 n4 n4 n4 n4 n4 n4

all following expressions take a long time (20-60 seconds) to complete:

> 42
-- nothing happens for 20 s, then REPL prints
42 : number

[Elm 0.18 / ubuntu]

process-bot commented 7 years ago

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

zwilias commented 7 years ago

While using the REPL, each expression is recorded and replayed whenever a new expression is entered, the final value being the one that is printed out. This allows doing stuff like

> import MyModule exposing (foo)
> foo "bar"
-- notice a bug, go fix it in code
> foo "bar"
-- ahh, all good.

Since a huge nested expression like the one you typed takes some time to compile and evaluate, every subsequent expression also needs to spend that time.

Note that you can reset the environment (hence clearing out the recorded history) using :reset.

endlessoblivion commented 6 years ago

Well, that explains the apparent behaviour, and while I understand the "hot-fix propagation" reasoning behind that, it still seems to deviate from the least surprise principle, i.e. what is reasonably expected from any REPL.

Indeed, I'd rather issue a (hypothetical) :replay command explicitly, while having the runtime context be kept in memory all along by default instead. But that's of course a highly subjective POV.