Skip to content
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

Evaluation of subexpressions reversed under eta expansion #11465

Open
som-snytt opened this Issue Apr 2, 2019 · 0 comments

Comments

Projects
None yet
2 participants
@som-snytt
Copy link

commented Apr 2, 2019

No one complained about this, which is described this way in the spec example:

scala 2.13.0-M5> def f = { println("F") ; 1 to 10 }
f: scala.collection.immutable.Range.Inclusive

scala 2.13.0-M5> f.foldLeft{ println("Z"); 0 }(_ + _)
F
Z
res0: Int = 55

scala 2.13.0-M5> f.foldLeft{ println("Z"); 0 } _
Z
F
res1: ((Int, Int) => Int) => Int = $$Lambda$954/0x0000000800623040@6f50d55c

Requisite "works in dotty":

Starting dotty REPL...
scala> def f = { println("F") ; 1 to 10 }                                       
def f: scala.collection.immutable.Range.Inclusive

scala> f.foldLeft{ println("Z"); 0 }(_ + _)                                     
F
Z
val res0: Int = 55

scala> f.foldLeft{ println("Z"); 0 } _                                          
F
Z
val res1: ((Int, Int) => Int) => Int = Lambda$1379/0x0000000802028040@56cfe6be

scala>

hrhino added a commit to hrhino/scala that referenced this issue Apr 3, 2019

Eta lifts function before args.
The comment says it, the spec says it, and most importantly, Dotty says it.

Maybe qualify for the coveted "performance" label by avoiding an
argument load.

Fixes scala/bug#11465.

@hrhino hrhino added the has PR label Apr 3, 2019

hrhino added a commit to hrhino/scala that referenced this issue Apr 3, 2019

Eta lifts function before args.
The comment says it, the spec says it, and most importantly, Dotty says it.

Maybe qualify for the coveted "performance" label by avoiding an
argument load.

Fixes scala/bug#11465.

@hrhino hrhino self-assigned this Apr 3, 2019

@hrhino hrhino added this to the 2.13.1 milestone Apr 3, 2019

hrhino added a commit to hrhino/scala that referenced this issue Apr 6, 2019

Eta lifts function before args.
The comment says it, the spec says it, and most importantly, Dotty says it.

Update the examples in the spec, which didn't say it.

Maybe qualify for the coveted "performance" label by avoiding an
argument load.

Fixes scala/bug#11465.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.