Maintainer: Adriano Ferreira <ferreira@cpan.org> Date: 17 Dec 2007 Last Modified: 17 Dec 2007 Number: 10 Version: 1
Status: Draft
The design of Perl 6 includes some unification mechanisms to bring some extra power to syntax and developers. One of such artefacts is the notion of meta-operators. With them, it is possible to construct augmented operators from existing ones.
The first of such meta-operators we're going
to look at is the quite simple '!' negation
prefix.
When applied to infix operators which produce a Bool result, they build a boolean-wise negated version.
== (numeric equality) / !== (numeric inequality) eq (string equality) / !eq (string inequality) ~~ (smart match) / !~~ (smart "mismatch") < (less than) / !< (not less than)
A few of these have traditional shortcuts: like
'!=' as a synonym of '!==' and 'ne'
which is the same as '!eq'. But from the point
of view of homogeneity, the negated operators
are more easily decipherable.
With negated relational operators, many expressions and algorithms will get a more natural code, without compromising their meaning and readability.
$x !eqv $y versus ! ( $x eqv $y )
The precedence of any negated operator is the same
as the base operator. To avoid visual confusion with
the '!!' operator, it is forbidden to modify any
operator already beginning with '!'.
Note. This article is an expansion of section "Negated relational operators" of Synopsis 03 .
$Revision$