-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add the
method
#5893
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
Add the
method
#5893
Conversation
I think that I proposed, a while ago, that it might be possible to completely elide
At the time, Jason Zaugg reported that he had tried it and it caused problems with newline inference: I believe that a new line starting with Could this be reconsidered for Scala 3, though? I would particularly like the implied endorsement that witness resolution is such an important feature of Scala that it gets the most privileged syntax we can give it. But I don't know the extent of the likely code breakage... |
I dunno. My initial reaction was "WTF?", but it does make a certain amount of sense. If implicit values are being repositioned as being "the definitive value for a type", then
reads rather well, IMO -- it's sensible English. I agree that speaking about it is likely to be somewhat awkward, but I don't think that's a killer problem. On first blush, I'm mildly in favor of this one... |
Compared to bare brackets, I think in code |
Interesting, how about bikeshed a little further on the syntax and go with the following: def f given B, C : String = {
imply a for A = the[B] // i.e. imply instead of implied
the[A].show
} |
Actually, why not go all the way? def f given B, C : String = {
imply a for A = by[B]
by[A].show
} I think it reads better with |
Devil's advocate: I think it's sometimes dangerous to create a syntax too similar to written english. When dealing with something like implicits, which carries a lot of rules, a seemingly innocent syntax may be misleading. While Especially short words like |
The main drawback of foo(bar, implicitly)
val foo: T = implicitly ...that looks out of place with foo(bar, the)
val foo: T = the while it still works great with foo(bar, infer)
val foo: T = infer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with the change, but I think that @LPTK's comments about the readability of the
vs. infer
are to the point.
When I chose the
for shapeless, it was the uniqueness of the inferred value that I was concerned with, more than the inference part. infer
, OTOH, focusses on the inference but doesn't suggest uniqueness, at least not so clearly.
One point in favour of the
is that I would expect that existing uses of the
(apart from in shapeless) in the ecosystem are far outnumbered by existing uses of infer
, so adopting the
would be much less disruptive.
Other things to consider ...
|
Ideally I would be able to keep writing
Or without being screwed when the third party who wrote the typeclass forgot to write the extra boilerplate. |
I agree that An alternative would be to have two methods. One would be Duplication like this is not nice, for sure. But I believe that the use case with type argument is common enough to warrant the optimal syntax for it. |
6e3cc33
to
39e1899
Compare
Replaces `infer`, has the Shapeless semantics. This required moving `DottyPredef` to src-bootstrapped since Scala 2.12 can't express the semantics of `the` in a straightforward way.
Merging this now, since too much breaks for pending PRs at the moment. |
the as a keyword - google and SO will need to improve their search algos :) |
the
replacesinfer
, with the Shapeless semantics. This requiredmoving
DottyPredef
to src-bootstrapped since Scala 2.12 can'texpress the semantics of
the
in a straightforward way.Based on #5887