For those who don't agree that there is a connection between ? and !… Actually,
there are some other places where ?↔! connection is implied. In fact, I will
probably never list all of them.

In regexes:
* <?> always succeeds, <!> always fails (and no question implied)
* <?{ … }> <!{ … }> tests for truthy and falsey values. Note that <{}> does
something completely different.
* a+? is for non-greedy, a+! for greedy (again no question implied)
* <before>, <?before>, <!before> (note that all three are supported, same goes
for <after>)



I would also do the job for the other side and provide some counter examples:
* There is a ! metaop but no ? metaop (e.g. !== but no ?==). If there was one,
it would practically be a noop because you wouldn't be able to use it on
anything non-iffy anyway. That said, it's still a weird case.
* There is [foo]? in regexes but no [foo]! . At first I thought that this is
intentional, given that ! may be needed for something else eventually, but
knowing that a+! works I'm no longer sure.

This raises a question: well… should we implement these too? Maybe this: “If
you’re gonna generalize, do it harder, but not too hard.”[^1] is relevant here,
but maybe not.

Bonus:
* In some cases the use of ? or ! is not related to this issue at all. e.g.
private methods (if we allow some things to have no opposites, why bother at
all?)


Anyway, that's some good food for thought I think.

[1] https://perl6advent.wordpress.com/2014/12/24/day-24-seeing-wrong-right/

Reply via email to