On Tue, Aug 24, 2004 at 02:31:00PM -0400, Aaron Sherman wrote:
: On Tue, 2004-08-24 at 08:24, Aaron Sherman wrote:
: 
: >     $foo => 'a' or 'b'
: 
: I was too focused on the idea of C<??>/C<::> as a pair-like construct,
: and I missed what should have been obvious:
: 
:       a ?? b :: c
: 
: IS
: 
:       given a { when true { b } default { c } }

I don't think so.  It's really much more like:

    if a { b } else { c }

: Which S4 tells us is:
: 
:       a -> $_ { when true { b } default { c } }
: 
: If you take the C<??> out of the ternary expression and make it a
: generic, binary logical operator that tests the topic for truth and
: executes lhs if topic is true and rhs if it is false, then that becomes:
: 
:       a -> $_ { b ?? c }
: 
: And further S4 tells us that that can become:
: 
:       a ~~ b ?? c
: 
: because C<~~> automatically topicalizes its lhs for its rhs.
: 
: So, with the very minor change of making C<??> binary instead of
: ternary, it turns out that we ALREADY HAVE a replacement for C<?:>, and
: didn't realize it!

Two big problems.  First, it goes against an aspect of C culture
that the current ??:: preserves.  Second, it has the wrong precedence.
The ~~ wants to be the precedence of a comparison operator, which want
to be tighter than the logical operators, which in turn wants to be
tighter than ??::.

: C<??> would also be darn useful in all sorts of places, as this lets you
: write things like:
: 
:       given a {
:               b ?? c;
:               say "We did the first step";
:               d ?? e;
:               say "We did the second step";
:       }
: 
: etc. My $0.02, but I think this is the way to go, and the whole C<::>
: thing just fades into historical note land.

I suspect such a use of ?? would be completely opaque to most people.
The small factorization win doesn't seem to me to be of sufficient
benefit to overcome all the problems.

Larry

Reply via email to