Control.Elab.ovlddisable
: Disable integer overloading
#325
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change adds the controls flag
ovlddisable
that prevents the toplevel functions~ + - * div mod < <= > >= abs
as well as integer and word literals from participating in overload resolution.These functions will take on their default types, which is
int
for the functions and integer literals, andword
for word literals.Description
This adds the flag to the Elaborator controls file.
It also adds a dummy "Overload.new" function that resolves variables and literals immediately, instead of waiting.
Motivation and Context
When teaching Standard ML, one thing to stress is how everything is properly typed.
Showing this off in SML/NJ leaves one bewildered:
This issue has even gotten worse from older releases, since in 110.79.0 the overloaded types were displayed as
[int ty]
instead of the scary'Z[INT]
.With this flag, one gets a much nicer error message:
This commit is not aimed at the development version of SML/NJ for good reason: this is a hack.
Really the compiler should either instantiate overloaded types before showing them to users such as MLton does.
But since SML/NJ is currently being used by students that have no use for language features such as overloading, this should be able to be hidden from view.
How Has This Been Tested?
This has not been extensively tested.