-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add @infix annotation #5975
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 @infix annotation #5975
Conversation
Current status: The new annotations are defined and explained, but the compiler does not interpret them yet. |
6e95d4d
to
0cfd797
Compare
2. An `@alpha` annotation can be given for all kinds of definitions. | ||
|
||
3. The name given in an `@alpha` annotation must be a legal name | ||
for the defined entities on the host platform. |
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.
We should not rely on "the host platform"'s notion of a legal name. Scala code should equally compile on all platforms. So this should be defined here (potentially as a valid Java identifier name).
s1 difference s2 // gives a deprecation warning | ||
|
||
s1 * s2 // OK | ||
s1.*(s2) // also OK, but unusual |
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.
The two "also OK" cases (s1.union(s2)
and s1.*(s2)
) kind of go against the motivation of achieving consistency. For consistency to be really applied, they should give a deprecation warning.
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.
Yes, it's a tradeoff. I believe though that declaring something @infix would be a strong enough social cue that people would follow it without the compiler having to enforce it. Always allowing method call syntax has the advantage that we can normalize programs. We can say x union y
desugars to x.union(y)
. If x.union(y)
was not legal that explanation would not be available.
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.
Meh. Yes, OK.
c94792c
to
68ebca8
Compare
The @infix part is done now. |
- Only checked under -strict - Not checked for symbols coming from Scala-2 - Infix alphanumeric is OK when followed by `{`
An elaboration of the proposal made by @sjrd in #5937.
@alpha
will come in a separate PR.