-
Notifications
You must be signed in to change notification settings - Fork 6
Update lexical analysis for the mod keyword #64
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
base: main
Are you sure you want to change the base?
Conversation
spec/lexical-analysis.md
Outdated
``` | ||
|
||
The `mod` keyword is treated as an infix operator for compatibility with OCaml syntax. Other infix keywords used in OCaml have been deprecated ([§](features-for-ml-compatibility.md#extra-operators)). In F#, integer modulus is calculated with the `%` operator and the user may define the `mod` keyword as a standard infix operator. | ||
|
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.
This is all true, but I wonder if, in view of this discussion, we should replace the last sentence by something like "A future FSharp.Core version may add a definition for the mod
operator."
And omit the usage example.
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 think that's a fine change. I'm pretty confident that even if a default implementation for mod
was provided it could still be redefined like how %
can be overridden too.
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.
Hmm. I am still not sure. The only reason to not deprecate mod
was its potential use as an alternative modulus operator. If we move it now to the list of keywords, it would be the only non-symbolic operator in F# and we would also need to change places like this one.
I'd love to hear the core team on this.
@T-Gro @vzarytovskii
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 spec should not be bothered with a hypothetical feature IMO, it should describe the language as is.
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 spec should not be bothered with a hypothetical feature IMO, it should describe the language as is.
@T-Gro
Thanks for the feedback. I am still not sure, though, what this means.
This is the current state:
- The 4.1 spec does not list
mod
as keyword, but only as deprecated ML compatibility feature in chapter 19. - The compiler recognizes
mod
as operator. - This language suggestion (if I understand it correctly) will deprecate its use as operator and keep it as reserved keyword.
Which one of the following options would you support?
- Keep
mod
in chapter 19. - In view of the above mentioned language suggestion, add
mod
to the list of reserved keywords, but don't mention it is an operator (because that will be deprecated). - Acknowledge the current compiler behavior by adding
mod
to the list of F# keywords in chapter 3.4 and mention that it is the only non-symbolic operator in F# and that it is user-definable.
9132978
to
323b348
Compare
This does not appear to be covered by an RFC but matches the F# compiler behavior.