-
Notifications
You must be signed in to change notification settings - Fork 72
LazyList.#:: not lazy due to parser rewriting of right-associative infix operators #127
Comments
what do you have in mind in opening this ticket, given the existence of scala/bug#1980? (I corrected your links to point to GitHub instead of JIRA) |
Thank you for the correction. |
FWIW, this should be much easier to fix in dotty where the problematic desugaring is not done during parsing but during typechecking, where we should have enough information to make the intermediate vals |
Cool. I was concocting a scheme to restore the laziness post-typer in a plugin, but it would clearly be cleaner to have the desugaring entirely post typer.
In the mean time, having a LazyList with an eager cons seems at the very least misleading, so maybe this issue has a collection-specific value independent of the existing scalac issues.
… On Jun 24, 2017, at 8:07 PM, Guillaume Martres ***@***.***> wrote:
FWIW, this should be much easier to fix in dotty where the problematic desugaring is not done during parser but during typechecking, where we should have enough information to make the intermediate vals lazy. I opened scala/scala3#2808 to track this.
―
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
There is a hack to make right-associative operations lazy and the current collections library already uses it. Try the same code with |
Good point. I added something similar to #128. Among other benefits, the de rigueur Fibonacci example now works without blowing stack. |
It looks like we can fix it in Scala 2.13 after all: scala/scala#5969. It requires a spec change so we should get Dotty on board, too. |
Putting on hold because we have to wait for Scala 2.13.0-M3. |
Tested with 2.13.0-M3. Works fine.
Scala 2.13.0-M2 evaluates only first element. |
Yes, see #345. |
Closed by scala/scala#6509 |
Evaluating
will immediately execute all the
println
s, even though.force
is never called and.evaluated
remainsfalse
. If one defines a left associativeprepend
with the same definition as#::
, thenwill behave in a properly lazy manner.
This is no great mystery, as the parser converts the definition of
xs20
to:This seems to be scala/bug#7333, which was closed as a duplicate of the somewhat less general scala/bug#1980
The text was updated successfully, but these errors were encountered: