question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

replace 'smaller', 'larger', 'equal' with 'Comparison.smaller', 'Comparison.larger', 'Comparison.equal'

See original GitHub issue

I’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:open
  • Created 5 years ago
  • Reactions:6
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
jvasileffcommented, Sep 14, 2018

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 for smaller(). If we’re going to change things up, I think it would be worth exploring other words to resolve the overload, like lesser and greater.

0reactions
gavinkingcommented, Sep 29, 2018

You can try this out on the 7409 branch.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found