Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:90383 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 93755 invoked from network); 8 Jan 2016 18:29:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Jan 2016 18:29:24 -0000 Authentication-Results: pb1.pair.com header.from=derokorian@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=derokorian@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.52 as permitted sender) X-PHP-List-Original-Sender: derokorian@gmail.com X-Host-Fingerprint: 74.125.82.52 mail-wm0-f52.google.com Received: from [74.125.82.52] ([74.125.82.52:33089] helo=mail-wm0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 11/77-55593-20000965 for ; Fri, 08 Jan 2016 13:29:23 -0500 Received: by mail-wm0-f52.google.com with SMTP id f206so146269690wmf.0 for ; Fri, 08 Jan 2016 10:29:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=MqaxZYWOsgZ3dAXrnfMyAOfdchQ3pDXTIn/OQOHzGoQ=; b=VxiZub1L+/v/r/GMpG1PAq73WAq3Bvx3hbMEnEMC1ifEriAB2c+Xtd0G7Zh+P6nUcR u9OWGQ5fzqRlzHoUxcrPavmYAYNim1KICZZUywIZc1xUOIVeBoZWdlBmXi/7zU8fcD1s MCOE0ZNTy4RkUpFJWwBfh7Omo4ugrtyNGBHQKofvINEZNJ58uvgzAlFzErZW2tWDgwqS xn1ITf1LQWGE5mqr3zNpsvyR7VFsPfZDEs2aumnHUgIsOHk6NwpHnnpV/YgJL5BwZAe2 QTAE5M1iLffsr4qL+rfi0D5RgptYr6LLYy9CtYpdJiKCFhEmjxfKU2sFFvuMWTaoEwiQ GnWw== MIME-Version: 1.0 X-Received: by 10.194.216.100 with SMTP id op4mr102367674wjc.85.1452277759587; Fri, 08 Jan 2016 10:29:19 -0800 (PST) Received: by 10.28.98.133 with HTTP; Fri, 8 Jan 2016 10:29:19 -0800 (PST) In-Reply-To: <568FFE13.2010304@gmail.com> References: <568FDA4B.60005@gmail.com> <568FFE13.2010304@gmail.com> Date: Fri, 8 Jan 2016 11:29:19 -0700 Message-ID: To: Stanislav Malyshev Cc: Dan Ackroyd , Rowan Collins , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=089e014935f4f9c0cb0528d6c3dd Subject: Re: [PHP-DEV] Deprecation of the Error Control Operator (@ symbol) From: derokorian@gmail.com (Ryan Pallas) --089e014935f4f9c0cb0528d6c3dd Content-Type: text/plain; charset=UTF-8 On Fri, Jan 8, 2016 at 11:21 AM, Stanislav Malyshev wrote: > Hi! > > > $counts[$item] ?? $counts[$item] = 1 ?? $counts[$item]++; > > 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. Doing such stuff is definitely > not the solution, if you hate @, then if() is way better, at least it's > clear. > > > $item = new StdClass; > > @$counts[$item] = "This is a bad use of error suppression."; > > > > There is no insertion, because arrays don't support object keys. The > > operation completly failed and so there should be an exception. > > No, there should not. If somebody tries to count garbage, I just don't > want to count it. I don't care about it, it's garbage. I agree with Dan on this one. Trying to use an invalid type as a key should produce something. Your argument that its garbage and you don't care may be valid for a specific use case, but it may also be a bug in another case. IE: it wasn't supposed to be an object, and the wrong variable was used, but tracking down that error if nothing is produced when doing something defined as invalid will be hard. If you don't want to count garbage, then you should use if() if (!is_garbage($key)) @$count[$key]++; > > > Currently that code fails silently. > > 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. > -- > Stas Malyshev > smalyshev@gmail.com > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --089e014935f4f9c0cb0528d6c3dd--