Skip to content

Placeholder FAQ claim overreaches #2381

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
som-snytt opened this issue Mar 6, 2022 · 5 comments
Closed

Placeholder FAQ claim overreaches #2381

som-snytt opened this issue Mar 6, 2022 · 5 comments

Comments

@som-snytt
Copy link
Contributor

Reproduction steps

scala 2.13.8> List(42).flatMap(List(_ + 1))
                                    ^
              error: missing parameter type for expanded function ((<x$1: error>) => x$1.$plus(1))

scala 2.13.8> List(42).flatMap(List apply _ + 1)
val res1: List[Int] = List(43)

Problem

The FAQ claims the function can't be written with placeholder syntax.

@SethTisue SethTisue transferred this issue from scala/bug Apr 20, 2022
@SethTisue
Copy link
Member

SethTisue commented Apr 20, 2022

I wouldn't call that "placeholder syntax", just because it's underscore? Looks like explicit eta-expansion syntax to me, and that's something else.

The actual FAQ wording is:

The latter function cannot be written using the _ syntax

I wouldn't mind changing the wording a bit, but I don't think we should remove the claim altogether given that this List apply _ business is corner-case style weirdness that would never have occurred to me to even try and certainly would never occur to a language newcomer.

@som-snytt
Copy link
Contributor Author

It's place holder syntax, where it's translated to x => expr(x).

I remember when I first saw someone point out how infix enables extra underscore powers. It seems magical at first, but is just ordinary syntax. Precedence rules matter in this example.

@SethTisue
Copy link
Member

It's place holder syntax, where it's translated

Oops, I thought I'd removed that sentence, after Dale set me straight. I've strikethroughed it.

@som-snytt
Copy link
Contributor Author

Taxi drivers are on strikethru, so let me know if you need a ride from the airport.

@som-snytt
Copy link
Contributor Author

FAQ is for brevity. That's why we call it FAQ for short.

@som-snytt som-snytt closed this as not planned Won't fix, can't repro, duplicate, stale Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants