On Sat, 22 Jul 2017 07:53:26 -0700, [email protected] wrote:
> This should work:
>
> Code:
> say (:?foo);
>
> Result:
> ===SORRY!=== Error while compiling -e
> Bogus statement
> at -e:1
> ------> say (:⏏?foo);
> expecting any of:
> colon pair
>
>
> Because these work:
>
> Code:
> say (:foo);
> say (:!foo);
>
> Result:
> foo => True
> foo => False
-1 from me:
1) Colonpairs are ubiquitous in the language, so there's large possibility of
introducing some unwanted ambiguity somewhere and it's hard to predict where it
might occur
2) Colonpairs are already one of the most complex syntax feature of the
language, requiring beginners to learn a wealth of syntax to understand most of
the common code.
3) Given (1) and (2), I'd expect any changes to extend their syntax to carry
large benefits, however, the proposal offers literally zero practical use and
the OP came up[^1] with this idea while trying to think of more cases to add to
the catalog of colon uses in Rakudo. The `?` prefix op at least coerces the
already-true arg to Bool (e.g. `?"foo" === True`) but in the case of the
colonpair, there's nothing to coerce, so there's absolutely no point in typing
the extra `?` and it's unlikely anyone would want to type it.
4) The OP makes the case that this syntax should exist solely for the sake of
consistency, by interpreting the `!` in `:!foo` syntax to mean the `!` op, and
there exists the `?` op. But if we follow that logic, it'd mean:
*) `!! ??` should be allowed too, to mean reverse ternary
*) `::!CLASS` should mean `anything but ::?CLASS`
*) `has $?foo` should be an alternative to `has $!foo`
*) `self?foo` should be an alternative to `self!foo`
*) `:-42foo` should parse just as `:42foo` parses
The point being that the current syntax is `":"` vs `":!"` not `":"` vs `":" +
some op`. And things that have "!" in them do not necessarily need to have a
"?" alternative.
In summation, there's no practical use of this feature and it is unlikely it'll
ever be used in real programs. The colonpair syntax is used across the entire
language and any changes to it have large impact. It's very hard to anticipate
any problematic ambiguity cases introduction of `?` into colon syntax might
have. And given lack of technical benefits of this feature, I do not think we
should accept the risks.
[1] https://irclog.perlgeek.de/perl6/2017-07-22#i_14907647