On 8 January 2016 at 18:21, Stanislav Malyshev <smalys...@gmail.com> wrote:
> Hi!

> This looks completely unreadable and I do not think it works:
> https://3v4l.org/PlAHH
> Seems to leave $counts as 1 always. But even if it didn't, I would never
> pass that on code review - it is very hard to understand what's going on
> and it is incredibly easy to break it.

Apologies, it should be:

$counts[$item] = ($counts[$item] ?? 0) + 1;

Which both works, and to me, is more readable than the @ version,  as
it doesn't rely on the person reading it knowing what the magic
behaviour PHP has when using an array that has not been set.

> it is very hard to understand what's going on
> and it is incredibly easy to break it.

You've had many years getting used to the current way of doing things.
At some point you should try to get used to new features.

> And that is exactly what I want it to do. Sometimes silent failure is
> *good*, I don't want to know about every little thing that could go
> wrong, I just want what's right to be done.
> Of course, your intent may be the opposite - but that's exactly the
> point, there's more than one use case.

Yes, yes, totally agreed. Sometimes you just want to be able to tell
the computer, "I know what I'm doing, don't nag" which is why the @ is
great, even though what it does might still use some improvement.

cheers
Dan

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to