Proposal To Revise Implicit Parameters

#163

implied was recently changed to delegate see https://github.com/lampepfl/dotty/pull/6649
It’s already the syntax in dotty 0.16.0-RC3

#164

Replacing “implied” with “delegate” seems a big step backwards for learnability. It will likely confuse and mislead those familiar with the design pattern having the same name. It will also confuse and mislead anyone with experience in C#, in which the “delegate” keyword means something different. I was quite happy with “implied,” and thought it added much needed clarity, but if the community insists on changing it, perhaps consider something else: “default” maybe? Conceptually a “default” instance of a type might be considered analogous to a default method parameter.

5 Likes
#165

Oooh that is a very nice suggestion, and “default” is also a noun :heavy_check_mark: !

#166

One problem I see: unfortunately, “default” is a longer form of “def” which creates confusion about their relationship.

1 Like
#167

Watch Martin’s recent Scala Days keynote. He makes a case for delegate and even mentions C#. It seems to me that the time for bikeshedding the new name has passed.

1 Like
#168

On the contrary: https://github.com/lampepfl/dotty/pull/6649#issuecomment-500428162

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.

4 Likes
#169

Forgive me if this has already been considered and discarded–if so, feel free to disregard. But what about instance as a keyword?

#170

It’s been considered, but was thought to be confusing for being the same terminology as is sometimes used as an instance of a class.

#171

Here is the slide with the list of names considered:

1 Like
#172

Thank you for the pointer to the presentation. It does give a great explanation of the larger syntax changes replacing implicits, which I totally support. It will make Scala much easier. However no reason is given for the word “delegate” other than to state that the committee considered lots of words. He says that in the end it doesn’t matter as long as people can remember it. I strongly disagree. This matters. The choice of keyword has a huge impact on the ease of learning this feature. When I explain this feature to co-workers new to Scala I will say it is like a default instance of that type. They will be trying to figure out in what sense what thing is delegating to what other thing. They might ask: how is this like the design pattern? I will be forced to say: “it has nothing to do with the design pattern. Just pretend it says default”. There is no good reason for this burden of cognitive dissonance. Please reconsider. “implied”, “default”, “supplied”, or “provided” - any of these would be preferable. “default” is my favorite.

2 Likes
#173

You would have to remind them that you’re going to send the thing to the United Nations, not ask it to do someone else’s work. (It’s the noun, not the verb. Yes, the verb is by far the more commonly used one, which is unfortunate for its usage here.)

3 Likes
#174

TODO: a compiler plugin that reformats the output of -Xlog-implicits as though they were U.N. Security Council deliberations:

:woman_judge: The council moves to elect a delegate for Traverse[List]!
:raising_hand_man: The delegate for Functor[List] nominates themself for Traverse[List].
:raising_hand_woman: Objection! The delegate for Monad[List] also demands to be considered!
:woman_judge: Motion failed due to diverging implicit expansion.

20 Likes
#175

That’s surprisingly reasonably to follow. Joke proposal or not, it might end up being a useful improvement in readability.

2 Likes