I had some thoughts lately about the Perl 6 operators, and wanted to bounce some ideas.


Firstly, regarding the string replication ops as documented in Synopsis 3, 'x' and 'xx', I'm wondering whether it might be better to have something that incorporates a '~', since that operation is about catenation.

Would perhaps '~*' work better than 'x' to signify better what the operation is doing; the '~' in this case means catenation and the '*' is meant to invoke 'multiply', not 'whatever'. So '~*' means "catenate a multiple of times".

This would then free up 'x' to be used for something else, if anything.

As for a substitution for 'xx', I'm less sure about that.


Was that operator called 'x' because it was the best or because that was how Perl 5 did it, and Perl 6 wanted to not change things if it didn't need to?


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.

Note that all the dyadic ops I am discussing are meant to be read as infix ops 

These are the boolean/logical ops you already have:

Niladic ops aka value literals / constants:
* Bool::False
* Bool::True

* not aka !, but ¬ alias could be added

* and aka &&, but ∧ alias could be added
* or aka ||, but ∨ alias could be added
* xor aka ^^ aka !===, but ⊻, ↮ aliases could be added
* ===, but xnor, ↔ aliases could be added

Now I'm not sure whether or not [also, andthen, orelse] have the desired semantics of any others or not, or whether [if, unless] could be used as a value-resulting infix operator or not.

But here are a few more dyadic:
* nand aka ⊼ aka ↑
* nor aka ⊽ aka ↓
* implies aka imp aka →
* nimp aka ↛
* if aka ←
* nif aka ↚

For that matter, as you know, every single boolean/logical operator could also have a bitwise analogue, if people were so inclined.


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.

Lots of the other ones I can think of apply to sets, and the ext/Set.pm bundled with Pugs already documents them quite well.

However, I think some set ops could also be used with hashes. For example, an alternate way of spelling "exists %foo{$bar}" is "$bar ∈ %foo" or "%foo ∋ $bar".

So, any thoughts?

-- Darren Duncan

Reply via email to