On Wed, 16 Oct 2019 at 18:10, Bob Weinand <bobw...@hotmail.com> wrote:

> what's the concrete advantage of this syntax as opposed to the already
> possible:
>
> $value = [
>         A1 => A2,
>         B1 => B2,
> ][expr()] ?? C;
>


What's the concrete advantage of switch over if-elseif? What's the concrete
advantage of if blocks over conditional jumps? The primary answer in all
three cases is surely "expressiveness".

If I came upon code like that, it would take me a while to understand its
intent - does $value end up as an array, or something else? what's the ??
there for, and when will expression C be used?

Now, it may be that the task in question isn't common enough to deserve its
own syntax, or you may not like the proposed syntax, but I think that's
very different from coming up with lots of clever ways of writing
something, and requiring new syntax to have a "concrete advantage" over
each one.

Regards,
-- 
Rowan Tommins
[IMSoP]

Reply via email to