HaloO,

I'm still contemplating how to get rid of the :: in the
ternary and make :: unequivocally available for a type
sigil and as a binary infix for symbol lookup. 

Here's a possible solution:

1) ?? becomes a binary operator that behaves as follows:
   a) it evaluates its lhs in boolean context
   b) if this is true, ?? evaluates its rhs such that it
      can't be undef
   c) if this is false, ?? returns undef

2) the precedence of ?? is above // which naturally catches
   the undef of a false condition.

This gives

   $x = $y < 3 ?? "small" // "large";

and possibly even a low precedence version

   $x = $y < 3 then      "small" err "large";  # hmm
               thence                          # old fashioned
               therefore                       # long, but clear

An implementation could read:

&*infix:<??> (&cond, &code)
  is parsed(...) # trait needed to insert {}?
{
   if &cond() { return &code() but defined }
   else       { return undef }
}


Comments?

TSa

Reply via email to