Larry Wall wrote:
On Wed, Oct 26, 2005 at 04:56:23PM -0600, Luke Palmer wrote:
: > Then ^T $x binds T to the kind of $x.  And $x.kind == $y.kind asks
: > if two objects are of the same type,
: : Don't you mean $x.kind eqv $y.kind?

I start to dislike the eqv name as generic value comparator because
it looks too much like the dual of xor. And there is the numeric
comparator <=> and its string companion cmp. But I don't want to re-open
the settled discussion of the operator names. OTOH, we could use the Num
kind as the prime representative of things that provide ==, !=, <=, >=,
<, > and <=>. Actually != is a bit odd there, but I guess no one would
accept <> even if it were available. But then keeping the ! logical negation
indicator we could use !< and !> instead of >= and <= respectively.

This is not too bad linguistically if we define

  <  below     !< not below  # >= is an alias
  >  above     !> not above  # <= is an alias
 ==  equal    =!= not equal
  =  equal     != not equal  # this one is just too beautiful
                             # to become Perl6 reality :)

and the string counter parts

 lt  <       ge  !lt   !<
 gt  >       le  !gt   !>
 eq ==       ne  !eq  =!=

Thus logical negation becomes a meta prefix operator like
meta postfix = deals with infix ops. The unless conditional
form then means exactly the same as outer logical negation

     if     $x     != $y      {...}
     if   !($x     == $y)     {...}   # same, also with space:   ! (...)
 unless     $x     == $y      {...}   # same
     if     $x not == $y      {...}   # same
     if not($x     == $y)     {...}   # same, also with space: not (...)
     if    ($x     == $y).not {...}   # same, method form

As a side effect the junctive annoyance

     if $x != any(1,2,3) {...}

automagically becomes

     if !($x == any(1,2,3)) {...}

The in-place modification unary method form then is $x.=not and might
have an optional boolean argument whose negated form becomes the new
boolean property. So $x.=not(0) means '$x becomes not false'. With bit
beeing an abbreviation of 'be it' just as not means 'no true' this can
be spelled $x.=bit(1) and read '$x becomes be it true' or some such.

If the Num kind models the mathematical ideal of real numbers then
$x == $y is synonym to false and $x != $y to true almost always. Anyone
doing numerics knows that you should actually use abs($x - $y) < $eps.
With $eps == 1 you get the integer case. Implementing Num as Int+Rem
where 0 !> Rem < 1 the Int comparison would be spelled

   $x ==:rem(0) $y

or perhaps better looking as

   $x == $y :rem(0)


   $x ==:int $y

Note that there is a slight difference to $x ==:eps(1.0) $y which is true
for $x = 3.8 and $y = 4.2 because their delta is 0.4 while 3 < 4 intwise.
The default fall-back in case of $x and $y beeing actual non-int nums could
use e.g. :eps(1e-6) which of course is configurable via pragma

  use Num:eps(1e-10);

The spelled out forms might read

   $x equal:int $y      # infix form

   $x.equal( :int, $y ) # method form

   equal :int, $x, $y;  # listop form

and correspondingly

   $x below:int $y      # infix form

   $x.below( :int, $y ) # method form

   below :int, $x, $y;  # listop form

This logical negation idea could even be driven further

  // err     /!/ nerr
  ||  or     |!| nor
  && and     &!& nand
  ^^ xor     ^!^ nxor eqv

The same can be done with the equality/identity checkers
where the intended concept is indicated by something between
the two = chars

    == generic num-like equality    =!=  generic num-like inequality
   =:= referential identity
  =::= symbol identity
   =^= kind identity

     = value copy
    := referential binding
   ::= symbol binding

and perhaps something like

   <::< type below
   >::> type above

   ^<  kind below   # or:  <^  <^=  <^<
   ^>  kind above

Now that infix:<::> has come available, maybe I mean:

    $x.kind :: $y.kind

Well or

      $x =^= $y

and also

     ^$x == ^$y

Sorry, couldn't resist.

Reply via email to