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

Clarify implicit in class params #9494

Closed
scabug opened this issue Sep 29, 2015 · 4 comments · Fixed by scala/scala#10568
Closed

Clarify implicit in class params #9494

scabug opened this issue Sep 29, 2015 · 4 comments · Fixed by scala/scala#10568

Comments

@scabug
Copy link

scabug commented Sep 29, 2015

It's not obvious that keyword implicit means "implicit parameter list" when it is not the first token in a parameter list.

This matters for class parameters, which may have other modifiers.

scala> class C(protected implicit val s: String, i: Int)
defined class C

scala> implicit val z = "hello"
z: String = hello

scala> new C()
<console>:13: error: could not find implicit value for parameter i: Int
       new C()
       ^

"What does 'override implicit' mean?" is a good ice breaker for a job interview.

@scabug
Copy link
Author

scabug commented Sep 29, 2015

Imported From: https://issues.scala-lang.org/browse/SI-9494?orig=1
Reporter: @som-snytt
Affected Versions: 2.11.7

@scabug
Copy link
Author

scabug commented Feb 14, 2017

@som-snytt said (edited on Feb 14, 2017 8:31:39 PM UTC):
I'd prefer leading leading implicit to mean implicit param section.

For def f(implicit x: X) to mean locally implicit, just

def f(x: X) { implicit val xx = x }

Somewhere, in the distant past, retronym said this was too finicky, but maybe the discussion is worth taking up again.

@scabug
Copy link
Author

scabug commented Feb 15, 2017

Stu Hood (stuhood) said:
Highly relevant as well: scala/scala3#1260

@som-snytt
Copy link

It's a beloved wart.

Recent discussion of implicit + default had me rereading the section.

@SethTisue SethTisue added this to the Backlog milestone Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants