Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:89946 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 23498 invoked from network); 31 Dec 2015 21:10:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Dec 2015 21:10:12 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.53 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.220.53 mail-pa0-f53.google.com Received: from [209.85.220.53] ([209.85.220.53:35918] helo=mail-pa0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BF/7F-51216-4B995865 for ; Thu, 31 Dec 2015 16:10:12 -0500 Received: by mail-pa0-f53.google.com with SMTP id yy13so63908216pab.3 for ; Thu, 31 Dec 2015 13:10:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type:content-transfer-encoding; bh=JEyg+UchRZf0lpBssiJoUY7blPRxVufoE4bL5FcLKrc=; b=ij9X5KRzOCeXsyfIPzHjlTqb070zwBkRKkMD6ch0uJaEsyKnUdwltdv3LhF3S5RSx3 golnOpj9vvIB26L6ofT1NtTa6EjRsYEJivt0aO7eygzKjwe/RXEkxfoezSh3+vopPaER Rncrw85eBxlkx1leTe3D4ylI9JNqSwMlt4g8GWEH0MaMXM+y+GeUZepfLwtb4IRcWb1X MZEb30xopt6N9ZDeN4okS107FfrbgCR5+4YNSjm7YmQbbnKk2anwf63f78TWG0iUN5m1 29AteOcuu/BUOxHM6pEvKHk2wSeacyc4mYf9Z0uWgqkoyhXJ75EhD13Old0LYob7d6PW phvw== X-Received: by 10.66.158.169 with SMTP id wv9mr102920284pab.138.1451596208807; Thu, 31 Dec 2015 13:10:08 -0800 (PST) Received: from Stas-Air.local ([2602:304:cdc2:e5f0:490c:9b9f:34fe:6779]) by smtp.gmail.com with ESMTPSA id fe6sm103649279pab.40.2015.12.31.13.10.07 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 31 Dec 2015 13:10:07 -0800 (PST) To: Junade Ali , internals@lists.php.net References: X-Enigmail-Draft-Status: N1110 Message-ID: <568599AA.4090209@gmail.com> Date: Thu, 31 Dec 2015 13:10:02 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Deprecation of the Error Control Operator (@ symbol) From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > I am looking to submit an RFC in order to remove the error suppression > operator in PHP, namely the @ symbol. I don't think it is a good idea, currently, for the following reasons: 1. A lot of functions produce error messages which may not be important in specific scenario, and the users should retain control over if they want them or not. Checking does not solve the problem, because a) it's a lot of unnecessary boilerplate code and b) the fact that you checked doesn't mean the situation is the same when you use what you checked - and race conditions are hard to debug. For some functions, you may not be even able to predict when they may output error messages - such as ones relaying them from third-party library. Of course, better way to handle them would be to return error status and use error reporting function, or have structured exception handling (or both) but it's not the case for many existing functions. 2. There are scenarios where @ saves a bunch of boilerplate code - simplest example: @$counts[$item]++; vs. if(!isset($counts[$item])) { $counts[$item] = 1; } else { $counts[$item]++; } Now imagine you have to write 20 of those - which is easier to write *and* read? Of course, one could argue the notice maybe should not be produced - but it is. > Aside from doing this, there are a number of alternatives: re-engineering > the behaviour of the error suppression operator and potentially bringing > into the scope of a function (e.g. silence()); this said, I still feel this > would contain similar issues as it wouldn't address the underlying issues > of lazy error suppression. I don't see how that would achieve anything but making it more verbose. The inherent problem is that some error reporting is unneeded in some contexts, while welcome in others. That's the problem that needs solving, the syntax is secondary to it. > Lastly, I recognise this will be a big change to PHP; but I feel it is > necessary to enhance the quality of PHP error handling. Let's not forget > that PHP managed to successfully deprecate the MySQL library. PHP did not just remove mysql library, it replaced it with better alternative. Which was well in place when the talk of the removal started. I agree that PHP error system could use a lot of improvement - in fact, it already started with move to exceptions and other changes - but it has to go much further before we could afford to remove @. I would say it definitely should not happen anywhere in 7.x line. -- Stas Malyshev smalyshev@gmail.com