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
spec: incorrect eta-expansion example in section 6.7.1 (Method Values) #6054
Comments
Imported From: https://issues.scala-lang.org/browse/SI-6054?orig=1 |
@SethTisue said: |
@gkossakowski said: |
@adriaanm said: |
@SethTisue said: |
@som-snytt said: |
@adriaanm said: |
@adriaanm said: |
@som-snytt said (edited on Mar 13, 2014 8:02:15 PM UTC): You bleat me to it [sic] but here's a version with some virtues. I'm especially happy with the Option example. (But the point, that your by-name param isn't evaluated during eta-expansion, isn't in the spec yet, I think.) Also happy with showing eval of other parts of the expr, since people are supposedly confused by what underscore encompasses. You know the guy who annoys you by coming up to your car at a stop light with a dirty squeegee? I hope I'm not that guy. |
@adriaanm said: |
@som-snytt said: |
Section 6.7.1 ("Method Values") in the language spec says:
bq. Example 6.7.1 The method values in the left column are each equivalent to the anonymous functions (§6.23) on their right.
But I don't think this expansion is correct. 6.7 says "e _ represents e
converted to a function type by eta expansion (§6.26.5)", and in 6.26.5,
we see that eta expansion introduces fresh names for subexpressions. So
the actual expansion is:
for some fresh names x0 and x1.
The difference matters if a subexpressions has side effects. So for
example with eta expansion we see the side effects immediately:
Whereas without the introduction of fresh names, evaluation is deferred:
because the behavior in this latter case is governed by 6.23
("Placeholder Syntax for Anonymous Functions"), not 6.26.5.
The text was updated successfully, but these errors were encountered: