John M. Dlugosz said [off-list]: > Darren Duncan darren-at-darrenduncan.net |Perl 6| wrote: >> I also know that >> given its current design, === and !=== just happen to have the same >> semantics as logical xnor and xor when given 2 Bool inputs, and so >> they serve the purpose. Having distinct xnor and xor operators is >> useful from partly a documentation perspective and from >> error-checking; a strict compiler or runtime should complain if >> non-Bool inputs are given to them. > > With the heritage as a free-typed language, the use of different > operators rather than overloading an operator based on type was a core > feature of Perl. You might not have two typed Bool arguments. You have > two arguments which might be considered boolean, or numeric, or string, > depending on what I want of it at the moment. > > So !=== between two arrays still does the Bool meaning, and asks if one > is empty and the other not. More serious with strings, which can be > strings or the serialized form of something else. === with strings will > be False if one contains "0" and the other contains "false", when both > are the same as XML attribute values of type XSD:boolean.
Actually, I'll correct myself. In Perl, I would expect the boolean-specific operators like and/or/xor/etc to accept any values at all as arguments, and evaluate them in a boolean context, using each object's notion of truthness. But my point is that, though the behaviour of xor and !=== is very different in the general case, when given two actual Bool arguments, their semantics would be the same, and so someone working in a pure Bool context would get the desired behaviour from !=== and === treated as xor and xnor. -- Darren Duncan