On Thu, Oct 24, 2019 at 5:19 PM Kosit Supanyo <webdevxp....@gmail.com> wrote:
> Hi Ken > > I totally agree with Andreas especially: > > One purpose of the operator should be that you don't have to repeat >> the variable. Here you do, e.g. $_SERVER['fname'] > > > But if this operator provide some way not to repeat the variable it will > make sense. For example: > > $_SERVER['fname'] !?? $user->setName($$) > I asked Andreas for their opinion on why this is bad in this context? Especially since if I were to use a traditional ternary or if condition, then I'd still be repeating the variable. > > But I think this functionality should be of something like pipeline > operator: > > // send tmp variable to the next expression unconditionally > $ret = $_SERVER['fname'] |> $user->setName($$); > // send tmp variable to the next expression only when $_SERVER['fname'] is > set. > $ret = $_SERVER['fname'] ?|> $user->setName($$); > > Also the syntax like above will be consistent with the proposed > safe-navigation operators. > I'm more interested in having a negation operator for the null-coalescing operator, especially since cognatively it should be easy to discern what it does. I've personally not seen |>, and I'd be confused as to what it does (e.g., is it a bitwise OR on a greater than comparison?). Thank you! The idea of $$ is neat, but not quite what I'm trying to achieve here. If anything, wouldn't that facilitate a different RFC? - Ken Stanley