# [S03] Negation metaoperator

0 views

### Jonathan Lang

Apr 6, 2007, 2:07:12 AM4/6/07
to p6l
Generalize the negated relational operators to apply to any infix
operator that returns a boolean. In terms of the standard operators,
this will add <&& || ^^ // and or xor err> to the family that is
implicitly equipped with logical negations.

For consistency's sake, you may also want to define junctive operators
<!& !| !^>. '!|' corresponds with the list-op 'none', although I can
think of no intuitive list-ops for the other two; we might have to
settle for '!all' and '!one'. If so, consider '!any' as a synonym for
'none', much like '!eq' and 'ne' are synonyms for each other.

Or just reduce the operators: [!&] and [!^]. Personally, I find
'!all' and '!one' to be more legible; but YMMV.

--
Jonathan "Dataweaver" Lang

### Larry Wall

Apr 13, 2007, 7:03:43 PM4/13/07
to p6l
On Thu, Apr 05, 2007 at 11:07:12PM -0700, Jonathan Lang wrote:
: Generalize the negated relational operators to apply to any infix

: operator that returns a boolean. In terms of the standard operators,
: this will add <&& || ^^ // and or xor err> to the family that is
: implicitly equipped with logical negations.

This will not fly, I'm afraid. These relationals are not typed to
return Bool, but rather Any. They work only because all normal values
do the boolean and defined roles, and the operator happens to evaluate
one or more of its Any values for its boolean or defined sense.
But the return value is one or another of the Any values (apart from
the XORs, which do at least return False unless only one of the Anys
is true, in which case you still get an Any).

So basically, either we'd have to pick and choose by precedence level
which infix operators allow meta-!, or open it up to all infix. That
could get a little strange:

\$a = \$b !but \$c;

Though one odd operator that might actually be useful is

\$a = \$b !% \$c; # short for \$a = \$b % \$c == 0

I doubt that would turn out to be a Best Practice though, and in
general even negated logicals are not going to be terribly useful
in reduce. So I'm not inclined to change anything currently.

Larry