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

Rename implied to delegate #6649

Merged
merged 5 commits into from
Jun 10, 2019

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jun 9, 2019

No description provided.

@odersky odersky marked this pull request as ready for review June 9, 2019 13:46
@jducoeur
Copy link
Contributor

jducoeur commented Jun 9, 2019

Huh -- this sort of comes out of left field. (I vaguely recall seeing it suggested on Contributors, but it hadn't seemed like one of the heavily-pushed options.) The docs don't appear to be in an experimental subdirectory as has been typical of these name changes: are you strongly considering this version?

@odersky
Copy link
Contributor Author

odersky commented Jun 9, 2019

@jducoeur I am strongly considering the new version, mostly because, after thinking quite intensively about it, the implied keyword feels more and more like a dubious compromise to me. Not implicit, but close enough so that it feels like an arbitrary change. The other problem with implied is that, being an adjective, it is easily confused with given and it is awkward to talk about its instances as values. This is reflected by experience reports of early users, who universally love given, but have doubts about implied.

I am now convinced we should be bolder. The feature merits having a simple name that can stand by itself. It must be a noun, analogous to object, class, or trait so that we can easily talk about what it defines. delegate is as good a candidate as any I have seen and it avoids the downsides of the earlier proposals.

After all the name wrangling here and on contributors I have come to the conclusion that there is no ideal pre-existing name for this feature. We have to create the name and establish it through usage. And delegate does well in that respect. It can be taken to mean exactly what we want. representative would have worked as well, but is too long, and repr is not pronounceable. evidence would work but is too type theoretic. Nothing else comes close IMO.

delegate is a synonym for representative which is shorter and easier to remember. When I try this out on people, the first reaction tends to be: Yes, but does this not already mean something else? I know delegates as a language feature in C#. There they define handlers for event types. Scala's proposed use of the word is a perfectly natural generalization of that concept. Delegates define handlers for types in the sense that they implement the operations defined by these types. And there is a notion of implicitness in both settings where the wiring between an event / method call and its delegate depends on the context.

In the end, it will not matter, as long as it a noun that is easy to pronounce and expresses roughly what we intend it to mean. delegate fits all these criteria.

@jducoeur
Copy link
Contributor

jducoeur commented Jun 9, 2019

Okay, useful to know -- thanks!

@japgolly
Copy link
Contributor

japgolly commented Jun 9, 2019

Delegate is also (and arguably more commonly) a verb. I suspect this might read to many users as an imperative command.

@@ -28,7 +28,7 @@ object ImportInfo {
* @param selectors The selector clauses
* @param symNameOpt Optionally, the name of the import symbol. None for root imports.
* Defined for all explicit imports from ident or select nodes.
* @param importImplied true if this is an implied import
* @param importImplied true if this is a delegate import
Copy link

@He-Pin He-Pin Jun 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

importImplied?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not have time to fix this yet. Right now only the surface is changed.

@godenji
Copy link

godenji commented Jun 10, 2019

Delegate is also (and arguably more commonly) a verb. I suspect this might read to many users as an imperative command.

That's exactly how I interpreted the change in the delegate a for A syntax, and not as, "define an implicit instance a using A". Not opposed to the change, but delegate can be intepreted as both a verb and a noun depending on usage (e.g. delegate a for A and def foo(x: T) = delegate match {...})

Is there really no word that captures the intended meaning? I'm sure this has been rehashed over and over, but it seems instance would be a natural fit.

@odersky
Copy link
Contributor Author

odersky commented Jun 10, 2019

I am not worried about the verb vs noun question, for two reasons:

  • It was not a problem for C# either.
  • Context: all the docs talk about delegate as a noun. So people might read it as a verb only if they have no clue what Scala is. And then it does not matter, because the verb meaning is also close enough to match their current understanding. E.g.
delegate for Ord[Int] { 
  def (x: Int) < (y: Int) = ...
}

If you want to read delegate as a verb it would actually work as well.

Both instance and impl were proposed (and even implemented!) and discarded. It's all in the previous PRs (Search for "witnesses").

I have come to realize that there is no good pre-existing term for this, we just have to pick one which is not completely wrong and establish its meaning through usage. delegate is not ideal but better than anything I have seen (and we have been through literally dozens of proposals over more than 6 months).

@anatoliykmetyuk
Copy link
Contributor

@odersky it works now, so you can merge it. I'll start the RC3 procedure once it is merged and passes CI on master.

@odersky
Copy link
Contributor Author

odersky commented Jun 10, 2019

@anatoliykmetyuk I am on my way to the contributors summit. I want to raise the issue there for feedback before going ahead.

@anatoliykmetyuk anatoliykmetyuk merged commit cf8fead into scala:master Jun 10, 2019
@anatoliykmetyuk anatoliykmetyuk deleted the add-contextual-delegate branch June 10, 2019 11:54
@odersky
Copy link
Contributor Author

odersky commented Jun 10, 2019

So, it's merged. We needed to do it before my ScalaDays talk tomorrow, hence the urgency. But everything is still subject to change. Over the next months we will use all of Dotty's language features in our own code. That should give us good feedback, which might prompt some changes.

@anatoliykmetyuk
Copy link
Contributor

RC3 is already in the Maven. Next step would be to upgrade the ecosystem from RC2 to RC3 and publish the blog article & other announcements. The current release status is available here: #6632. I'll do the upgrading of the ecosystem today, when should we publish the announcements? /cc @biboudis

@biboudis
Copy link
Contributor

Tomorrow morning 9:00 am 🎉🎉🎉

@zynque
Copy link

zynque commented Jun 22, 2019

Please bring back "implied"!
I have mentored relatively inexperienced Scala developers coming from Java, and the old implicits were always the most difficult hurdle, and often the reason some of them are highly critical of the language. So when recently reading the docs for Dotty, particularly the parts about the changes to implicits, and was very excited. But a couple days later I reopened the docs and saw the "implied" keyword suddenly replaced with the cryptic and misleading "delegate". I am so shocked and disappointed. I just had to reach out and say something. The delegate keyword is incredibly misleading and totally ruins all the great work you've done so far to make implicits more comprehensible. For those new to the language delegate might bring to mind the C# keyword, or the delegate design pattern, neither of which is remotely close to what Scala is trying to convey, and thus only adds to the confusion. For those familiar with the language, it is a jarring and unexpected change in vocabulary that doesn't make much sense. Please please bring back implied and make Scala 3 the beautiful language it deserves to be!

@zynque
Copy link

zynque commented Jun 22, 2019

If you must insist on moving away from "implied", might I suggest "default" as a better alternative keyword?

default IntOrd for Ord[Int] {
def compare(x: Int, y: Int) =
if (x < y) -1 else if (x > y) +1 else 0
}

@pkolaczk
Copy link

pkolaczk commented Jul 6, 2019

Delegate means traditionally when one object delegates calls to another object. IMHO implied or implicit was much better. I like default as well.

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 this pull request may close these issues.

None yet

10 participants