On the one hand, I've had 25 years of being annoyed about the idiom

        if foo() == True ...

So I'd be delighted if P6 were to treat that case as a fatal compile-time

And given that "==" are "!=" are just funny ways of writing "!xor" and
"xor", that prohibition could reasonably be extended to all statically-typed
expressions (not just constants), with the error message suggesting the use
of "!xor" or "xor" instead.

On the other hand it feels it'd be wrong if foo() ~~ bar() simply ignored
the value of one of its operands based on the type of the other.

Overall I'd rather see a solution that factors out the implicit "last" from
the implicit "$_ ~~".

My feeling is that "if" and "when" should be for the implicit "last", since
they're all alphabetic tokens; then it's just a case of deciding how to
spell the contextualizer.  The most obvious would be

 if == VALUE-TO-MATCH {...}
 if ~~ VALUE-TO-MATCH {...}
 when == VALUE-TO-MATCH {...}
 when ~~ VALUE-TO-MATCH {...}

however I'm not sure if that conflicts with any prefix:<~~> or
prefix:<==>, and it also conflicts with Huffmanizing the implicit match
to something shorter than the explicit comparison.

One possibility is to make all options explicit:

 if= VALUE-TO-MATCH        {...}  # no implicit last
 when= VALUE-TO-MATCH      {...}  # implicit last

and then make bald "if" and "when" be DWIMmy shorthand.

Oh, and then "A ~~ B" just works like "?! (A) xor B", if B is a Bool.


PS: I also considered some other possibilities, but I don't like them as

 if -> VALUE-TO-MATCH {...}
 when -> VALUE-TO-MATCH {...}

 -> if VALUE-TO-MATCH {...}
 -> when VALUE-TO-MATCH {...}

 .if VALUE-TO-MATCH {...}
 .when VALUE-TO-MATCH {...}

 ==> if VALUE-TO-MATCH {...}
 ==> when VALUE-TO-MATCH {...}

Reply via email to