Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Numerification of Order:: constants

37 views
Skip to first unread message

Mark Reed

unread,
Aug 17, 2006, 12:54:27 PM8/17/06
to perl6-l...@perl.org
S03, lines 418-420: "[cmp] always returns C<Order::Increase>,
C<Order::Same>, or C<Order::Decrease> (which numerify to -1, 0, or +1)."

Shouldn't Order::Increase numerify to +1 and Order::Decrease to -1? In
which case it would be clearer to put them in respective order above...

Mark A Biggar

unread,
Aug 17, 2006, 1:13:50 PM8/17/06
to Reed, Mark (TBS), perl6-l...@perl.org


"$a cmp $b" has always been define as sign($a - $b), so the above numerification are correct. Thnk of them as describing the sequence ($a, $b). if the sequence is increasing then "$a, cmp $b" returns Order::Increase or -1.

Mark Biggar

--
Mark Biggar
ma...@biggar.org
mark.a...@comcast.net
mbi...@paypal.com

David Green

unread,
Aug 17, 2006, 1:27:21 PM8/17/06
to perl6-l...@perl.org

Maybe you could view it either way, although I think going the other
way around would make more sense only if the names were Order::Lower,
::Same, ::Higher.
S03 matches the old cmp semantics in that "3<=>4" returns -1, which
represents increasing order because reading left-to-right, we go from
3 up to 4.

However, what I'm wondering is whether Order::Same is "but true" and
the others "but false"? (Which makes cmp in boolean context the same
as eqv, but it seems to make sense that way.)


-David

Larry Wall

unread,
Aug 17, 2006, 1:46:58 PM8/17/06
to perl6-l...@perl.org
On Thu, Aug 17, 2006 at 11:27:21AM -0600, David Green wrote:
: However, what I'm wondering is whether Order::Same is "but true" and
: the others "but false"? (Which makes cmp in boolean context the same
: as eqv, but it seems to make sense that way.)

We should not be encouraging people to use cmp to mean eq. All that will
do is result in Great Confusion.

Larry

Larry Wall

unread,
Aug 17, 2006, 2:07:42 PM8/17/06
to perl6-l...@perl.org
I don't know if I've made this clear, but over the last few years I've
been treating "but True" and "but False" as design smells. They're
fine as a workaround for dire circumstances and uncooperative types,
but you'll not find me designing very many of the core interfaces to
use them, or other run-time mixins, for that matter. Solutions involving
"but" will generally be rejected, in other words.

Larry

Alexey A. Kirithun

unread,
Aug 18, 2006, 10:50:39 AM8/18/06
to perl6-l...@perl.org
On Thursday 17 August 2006 21:27, David Green wrote:

> However, what I'm wondering is whether Order::Same is "but true" and
> the others "but false"? (Which makes cmp in boolean context the same
> as eqv, but it seems to make sense that way.)

OTOH, C programmers can as well assume 'cmp' being an equivalent of '! eqv' in
boolean context; after all that's how strcmp() works... The same goes for
assembly programmers.

(* goes back lurking *)

--
Alexey A. Kiritchun

0 new messages