Raku / old-design-docs

Raku language design documents
https://design.raku.org/
Artistic License 2.0
124 stars 36 forks source link

Numification of Order:: enumerations is backwards. #61

Closed ShimmerFairy closed 11 years ago

ShimmerFairy commented 11 years ago

By current spec,

+Order::Decrease ==  1
+Order::Same     ==  0
+Order::Increase == -1

Not only does this numification run counter to popular interpretations of "Increase" and "Decrease", but also requires a different interpretation:

say 5 cmp 7
OUTPUT: Increase

(From the LHS, you must increase to get to the RHS)

say +(5 cmp 7)
OUTPUT: -1

(From the RHS, you must go down (subtract/add negative) to get to the LHS)

I don't know about you, but this weird numification of words in addition to the differing interpretation between the object and its numification is broken. I recommend Decrease == -1 and Increase == 1.

KamilaBorowska commented 11 years ago
glitchmr@tomato ~> perl -E'say 5 <=> 7'
-1

I don't see a problem. This behaved like that back when Perl added spaceship operator (Perl 3, I think). It means that the first value is smaller than the second. Then again, perhaps swapping Decrease and Increase could work...

quietfanatic commented 11 years ago

Personally I think the problem is that Increase and Decrease are confusingly named. I cannot figure out what they mean from their names. Why not change them to Less and More, akin to Haskell's Ordering type?

tony-o commented 11 years ago

Konrad's example is dead on

On Thursday, November 7, 2013, quietfanatic wrote:

Personally I think the problem is that Increase and Decrease are confusingly named. I cannot figure out what they mean from their names. Why not change them to Less and More, akin to Haskell's Ordering type?

— Reply to this email directly or view it on GitHubhttps://github.com/perl6/specs/issues/61#issuecomment-28039533 .

Sent from Gmail Mobile

KamilaBorowska commented 11 years ago

@tony-o: Not sure what you talk about. say was added in Perl 5.10, but in older versions, following code should work.

glitchmr@tomato ~> perl -le'print 5 <=> 7;'
-1
tony-o commented 11 years ago

I was saying that you’re example explains why the values for INCREASE and DECREASE make sense - sorry for the confusion.

From: Konrad Borowski Konrad Borowski Reply: perl6/specs reply@reply.github.com Date: November 8, 2013 at 10:32:37 AM To: perl6/specs specs@noreply.github.com Subject:  Re: [specs] Numification of Order:: enumerations is backwards. (#61)
@tony-o: Not sure what you talk about. say was added in Perl 5.10, but in older versions, following code should work.

glitchmr@tomato ~> perl -le'print 5 <=> 7;' -1

— Reply to this email directly or view it on GitHub.

Timbus commented 11 years ago

Okay this is frustrating. All of you are saying this sentence is pleasant to grok:

5 <=> 7 gives -1. It means that the first value is smaller than the second. It is called Increase.

lue's idea is to simply swap Increase and Decrease. ergo: 5 <=> 7 gives -1. It means that the first value is smaller than the second. It is called Decrease.

Makes perfect sense to me.

FROGGS commented 11 years ago

The problem is that when you think of Decrease, you're thinking of a range which values become less. And when you think about ranges, you usually imagine them from left-to-right.

pmichaud commented 11 years ago

Per commit 5e2c4205 , the names have been changed to Order::Less, Order::Same, and Order::More, which numerify to -1, 0, and +1.

5 <=> 7     # Order::Less, -1
5 <=> 5     # Order::Same, 0
5 <=> 3     # Order::More, +1

Closing issue.

Pm

tony-o commented 11 years ago

This is backwards. The number on the left needs to be increased to be the number on the right, now it is more confusing.

On Tuesday, November 12, 2013, Patrick R. Michaud wrote:

Closed #61 https://github.com/perl6/specs/issues/61.

— Reply to this email directly or view it on GitHubhttps://github.com/perl6/specs/issues/61 .

Sent from Gmail Mobile

pmichaud commented 11 years ago

@tony-o: The history for much of this is rooted in the C language strcmp() function, and has been carried forward through Perl. In C, strcmp(a,b) would return a negative value if a is less than b, zero if a is equal to b, and a positive value if a is greater than b.

Perl 5's cmp and <=> operators keep these same semantics, returning -1, 0, and 1 depending on whether the left hand operand is less than, equal to, or greater than the right hand operand.

Perl 6 is simply continuing this tradition. If the left operand is less than the right operand, the operator returns a value less than zero. If the left operand is greater than the right operand, the operator returns a value greater than zero. This is how it's always worked in Perl (5 and 6), and changing the return values for cmp, <=>, and leg will simply be more confusing.

Pm

tony-o commented 11 years ago

I wasn’t saying the -1, 0, 1 is backwards.  Saying ‘Increase’ when the left value needs to be decreased to be equal is backwards, EG, changing the verbiage is confusing.

5 <=> 7 = -1 is fine and 5 should be INCREASE(d) to be equal .. to make it say DECREASE is confusing

--  Tony O'Dell (916) 220-9336 From: Tony O'Dell Tony O'Dell Reply: Tony O'Dell tony.odell@bestxperts.com Date: November 12, 2013 at 8:24:03 AM To: perl6/specs reply@reply.github.com Subject:  Re: [specs] Numification of Order:: enumerations is backwards. (#61)
This is backwards. The number on the left needs to be increased to be the number on the right, now it is more confusing. 

On Tuesday, November 12, 2013, Patrick R. Michaud wrote: Closed #61.

— Reply to this email directly or view it on GitHub.

Sent from Gmail Mobile

KamilaBorowska commented 11 years ago

What about mapping the ordering names to comparison operators. My proposal would be to have Greater (1), Equal (0) and Lesser (-1) enum values.

Benabik commented 11 years ago

@tony-o - Perhaps you missed the part where @pmichaud said we already renamed it from Decrease/Increase to More/Less (for 1/-1).

@GlitchMr - I'm somewhat confused as how Greater and Lesser are significantly different than More and Less.

KamilaBorowska commented 11 years ago

Well, Greater looks like gt, Lesser looks like lt, and Equal looks like eq.

quietfanatic commented 11 years ago

I like Lesser and Greater better than my original proposal. On Nov 12, 2013 11:22 AM, "Konrad Borowski" notifications@github.com wrote:

Well, Greater looks like gt, Lesser looks like lt, and Equal looks like eq .

— Reply to this email directly or view it on GitHubhttps://github.com/perl6/specs/issues/61#issuecomment-28324172 .

tony-o commented 11 years ago

Lesser and greater is better

--  Tony O'Dell (916) 220-9336 From: quietfanatic quietfanatic Reply: perl6/specs reply@reply.github.com Date: November 12, 2013 at 12:05:05 PM To: perl6/specs specs@noreply.github.com Subject:  Re: [specs] Numification of Order:: enumerations is backwards. (#61)
I like Lesser and Greater better than my original proposal. On Nov 12, 2013 11:22 AM, "Konrad Borowski" notifications@github.com wrote:

Well, Greater looks like gt, Lesser looks like lt, and Equal looks like eq .

— Reply to this email directly or view it on GitHubhttps://github.com/perl6/specs/issues/61#issuecomment-28324172 .

— Reply to this email directly or view it on GitHub.