replace 'smaller', 'larger', 'equal' with 'Comparison.smaller', 'Comparison.larger', 'Comparison.equal'
See original GitHub issueI’ve always hated that the cases of Comparison
(smaller
, larger
, equal
) pollute the toplevel namespace of ceylon.language
.
I could change the definition of Comparison
to this:
"The result of a comparison between two [[Comparable]]
objects: [[larger]], [[smaller]], or [[equal]]."
see (interface Comparable)
tagged("Comparisons")
shared class Comparison
of larger | smaller | equal {
shared actual String string;
"The value is exactly equal to the given value."
shared new equal {
string => "equal";
}
"The value is smaller than the given value."
shared new smaller {
string => "smaller";
}
"The value is larger than the given value."
shared new larger {
string => "larger";
}
"The reversed value of this comparison."
since("1.2.0")
shared Comparison reversed
=> switch (this)
case (equal) this
case (larger) smaller
case (smaller) larger;
}
So you would write Comparison.smaller
, Comparison.larger
, Comparison.equal
.
This would be a breaking change, of course.
WDYT, folks?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:6
- Comments:14 (14 by maintainers)
Top Results From Across the Web
Comparison operators - order items using the greater than ...
C# comparison operators check the order of values. ... Less than operator <; Greater than operator >; Less than or equal operator <=...
Read more >Greater Than, Less Than, and Equal - 2nd Grade Math (2.NBT.4)
In this lesson, we will compare two three-digit numbers based on meanings of the hundreds, tens, and ones digits, using greater than, ...
Read more >Comparison and Logical Operators - Codecademy
Comparison Operators Greater than ( > ) — returns true if the value on the left is greater than the value on the...
Read more >Comparison operators - cppreference.com
The two-way comparison operator expressions have the form ... 3) Returns true if lhs is less than or equal to rhs, false otherwise....
Read more >Equality comparisons and sameness - JavaScript | MDN
Triple equals ( === ) will do the same comparison as double equals (including the special handling for NaN , -0 , and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Not a big deal either way, but I like them being toplevels; less hassle and clutter with imports.
Is there any practical benefit to requiring the import?
What has really bugged me is the top-level function
smallest()
, which is ungrammatical forsmaller()
. If we’re going to change things up, I think it would be worth exploring other words to resolve the overload, likelesser
andgreater
.You can try this out on the
7409
branch.