develooper Front page | perl.perl6.language | Postings from July 2006

Re: ===, =:=, ~~, eq and == revisited (blame ajs!) -- Explained

Thread Previous | Thread Next
Larry Wall
July 14, 2006 12:56
Re: ===, =:=, ~~, eq and == revisited (blame ajs!) -- Explained
Message ID:
On Thu, Jul 13, 2006 at 10:56:59PM -0700, Darren Duncan wrote:
: Now, I didn't see them yet anywhere in Synopsis 3, but I strongly 
: recommend having negated versions of all these various types of 
: equality tests.  Eg, !== for ===, nev for eqv, etc.  They would be 
: used very frequently, I believe (and I have even tried to do so), and 
: of course we get the nice parity.

My gut feeling contradicts yours--I think these are going to be far
rarer in practice than == and eq, so they don't warrant yet more
special forms that have to be memorized.

And !== is too easy to confuse with != visually, or with !(==) semantically.
For such long operators, I'd try to do exact syntactical composition rather
than replacement, so they'd be !=== and neqv, probably, along with !=:=.
Maybe even go with !eqv rather than neqv, and make ! into a metaoperator
on relationals.  Then !== and !eq would be identical to != and ne.

But a lot of the time the negated versions are going to be disallowed anyway,
simply because English mangles junctions when it does "not raising".

    Valid English:
	If X doesn't equal one or two or three, say "out of range".

    Naïve Perl:

	if $x != 1 | 2 | 3 {
	    say "out of range";

But that's wrong because Perl doesn't do "not raising", so the statement
above always prints "out of range".  You should have said one of:

	if not $x == 1 | 2 | 3 {
	    say "out of range";

	if $x != 1 & 2 & 3 {
	    say "out of range";

So either we have to make Perl do not-raising like English, which will
probably confuse non-English speakers, or we have to disallow negative
operators from participating in junctional logic, or we have a huge
educational problem (read FAQ).  My money is currently on disallowing
distribution of junctions over negated operators, and forcing people
to do not-raising explicitly, at least in the syntactic case above.
Perhaps we can still allow the semantics where it's not likely to be
confused with English.

Anyway, that's just another reason for going slow on throwing in the
negated versions.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About