Buddha Buck wrote:
Secondly, regarding the Bool type, I think it would be useful for Perl 6 to
define the full complement of dyadic logical operators, of which I count a
few that you don't appear to already have.  Probably the best place is in
Synopsis 32.


There are 16 dyadic logical operators, not all of which make sense to
have.    You name 10.

I think you answered your own criticism right there. The ones I didn't mention are ones that don't make sense to have.

2 of the 16 dyadic operators always result in false or true respectively, regardless of the arguments, same as 2 of the 4 monadic operators, and same as the only 2 niladic operators, contradiction/⊥ and tautology/⊤; only the last make sense to have. Another 2 of the 16 always result in a certain one or other of the arguments, respectively, regardless of the value of the second argument; they are like 1 of the 4 monadic operators that always results in its argument, and so isn't useful. Another 2 of the 16 always result in the opposite of the previous 2 I mentioned, and these are like the only 1 useful monadic operator, not/¬, that returns the opposite of its argument.

This then leaves 10 dyadic operators that are actually useful, of which Perl (and most languages) clearly includes 3 as standard infix operators: and, or, xor/!===, === (xnor), which leaves 6 others of which AFAIK implies/→ is the most commonly used of those.

Now, clearly ←,↚ are redundant with →,↛ if you just switch the operands around, but then by the same token <,≤/<= are also redundant with >,≥/>= if you just switch the operands, but it is useful to have both versions regardless.

I'm certain I know the semantics of these (and chooses the minimum of
the two, or the maximum, xor checks for difference, xnor checks for
sameness), but I'm uncertain of some of the rest...

But here are a few more dyadic:
* nand aka ⊼ aka ↑
true unless both operands are true

* nor aka ⊽ aka ↓
true if both operands are false

* implies aka imp aka →
true unless left operand true and right operand false.

* nimp aka ↛
true if left operand true and right operand false?

* if aka ←
true unless left operand false and right operand true

* nif aka ↚
true if left operand false and right operand true?

See these urls which were 2 of my primary references when building my lists:

  http://en.wikipedia.org/wiki/Logical_connective

  http://www.rbjones.com/rbjpub/logic/log048.htm

They should give you all the details.

The other six, which don't depend on the value of both operands, would
(if they existed) have the names false, left, right, nright, nleft,
and true.

I believe traditionally they are called: contradition, p, q, ¬q, ¬p, tautology (where p and q are the names of the arguments).

Thirdly, there are I'm sure a number of other aliases that could be added to
other ops, such as ≤ and ≥ for <= and >=, and ≠ for one of the inequality
operators, although that last one would probably make more sense if = was
the equality test operator, so maybe best to avoid ≠ then.

Perhaps ≡ and ≢ as aliases?

Well that's a thought, since those actually talk about 'identical' rather than 'equal', though I believe for purposes of logic (ignoring geometry say) they mean exactly the same thing, and I prefer the = and ≠ symbols.

For all of that matter, I think that Perl 6 would look a lot prettier if it used = as the generic equality test op (what === is used for now) and used the likes of := for assignment/binding/etc.

I don't know if using = for assignment is actually liked by people because they think it looks better or just because it has momentum say from Perl 5 and C et al. Probably the single main advantage I can see for needing a single character there is it combines easily with infix ops to make =foo ops, not that this still can't be done another way.

Larry, did you choose = for assignment and == etc for comparison because you thought that looked prettier, or because that was the C/etc convention that you decided to copy?

-- Darren Duncan

Reply via email to