Skip to content

REPL eagerly evaluates lazy vals #1440

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

Closed
cswinter opened this issue Aug 3, 2016 · 3 comments
Closed

REPL eagerly evaluates lazy vals #1440

cswinter opened this issue Aug 3, 2016 · 3 comments

Comments

@cswinter
Copy link
Contributor

cswinter commented Aug 3, 2016

scala> lazy val a = { println("side effect"); 0 } 
side effect
a: Int = 0

What scalac/ammonite do:

scala> lazy val a = { println("side effect"); 0 }
a: Int = <lazy>
@kcsongor
Copy link
Contributor

kcsongor commented Aug 15, 2016

I think this is an improvement, rather than a regression.

To me it makes perfect sense that when REPL prints the result of an expression, it has to force its value. Printing feels like a bit of a hack. That being said, this still might be unintended behaviour

@Jasper-M
Copy link
Contributor

If the REPL immediately forces lazy vals, then there is absolutely no use for lazy vals in the REPL.

@felixmulder
Copy link
Contributor

New REPL doesn't do this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants