Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87185 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 23148 invoked from network); 15 Jul 2015 12:00:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Jul 2015 12:00:20 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.170 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.170 mail-wi0-f170.google.com Received: from [209.85.212.170] ([209.85.212.170:35898] helo=mail-wi0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FB/44-27477-35B46A55 for ; Wed, 15 Jul 2015 08:00:19 -0400 Received: by widjy10 with SMTP id jy10so126818404wid.1 for ; Wed, 15 Jul 2015 05:00:16 -0700 (PDT) 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=1RWoSwRmTaiQCCZPRR3PohBNwdMc07Nosqgrqbuyk9c=; b=XLnlixGRWXlOHvmKuEQYok/wXDipYdNr0OiHyDhxmSUgAR5t/XNtUuYSM/0jw1ej/V PXiLYrMfE263a+uyxNSIJ4xRaP8onKMO0WgoLEWJuaQ24HFTUYv5TIN8aFe2U5FX6QHM nXDcBKVDPbpCw/e6Gl+qxRkCN8OuRLTJtfFEWa8V4HKJ2RUWwl3BDpzwn7zwmv8SAdfP UG0WeGql5AgwZtUmwi7L695KP/5jEbYIGqwvX5ZsNQpkcqTTWRyiOoMdnNyS4eSm2lPt v67jZAB68zdbH5YkjxjER8xRydPACXAFTiNpe1RYKifg3jN2U794nZFap5FtThAQrzDR GGug== X-Received: by 10.194.205.101 with SMTP id lf5mr8202522wjc.37.1436961616243; Wed, 15 Jul 2015 05:00:16 -0700 (PDT) Received: from [192.168.0.136] ([62.189.198.114]) by smtp.googlemail.com with ESMTPSA id qq1sm7616810wjc.0.2015.07.15.05.00.14 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Jul 2015 05:00:15 -0700 (PDT) To: "internals@lists.php.net" References: <55A63C90.8000705@gmail.com> Message-ID: <55A64B40.4000609@gmail.com> Date: Wed, 15 Jul 2015 13:00:00 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Core functions throwing exceptions in PHP7 From: rowan.collins@gmail.com (Rowan Collins) Yasuo Ohgaki wrote on 15/07/2015 12:20: > Engine exception is a little different. The main motivation for engine > exception is > to give a chance to users for graceful program termination. Functions > can achieve > the objective by E_RECOVERABLE_ERROR mostly. This is simply incorrect, as demonstrated by conversion of existing E_RECOVERABLE_ERROR states in the engine to Throwable, and nullified RFCs which would have, had EngineExceptions not passed, convert engine-issued E_ERRORs into E_RECOVERABLE_ERROR. > If we are going to adopt exception for "functions", it would be better > to have > switch that convert all errors to exceptions. Strongly disagree. A runtime switch would be a horrible consistency nightmare for userland, and many of the existing functions which desperately need better error-handling (e.g. file I/O) don't issue an error at the moment anyway. The only reason (and it's a massive reason, don't get me wrong) not to start throwing exceptions all over the core is backwards compatibility. New functions do not, by definition, have anything to be backwards compatible with. So my suggestion is, to come up with some reasonable definition of "new area of functionality" where we can do things in a way which everyone seems to agree is basically better, i.e. throw Exceptions. - The rule shouldn't apply for new variations or close cousins of existing functions (e.g. the json_decode_to() that was briefly discussed should use similar conventions to json_decode() if it were implemented), only in cases like this where we're adding a new set of functions (the manual puts random_bytes and random_int in their own "book": http://php.net/manual/en/book.csprng.php). - It also shouldn't be used for "routine" errors (like File Not Found), only in place of conditions which can justify a fatal error - both for the intuitive reason that an uncaught exception *is* a fatal error, and the procedural reason that we may want to decide a policy for "routine" error handling at a later date. At some point, we should revisit the general error-handling strategy of both the language and the core library, but 7.0 having been somewhat derailed (in my opinion) by the endless debates about scalar type hints, it will have to wait until 8.0 before we can do anything radical to existing functions. Regards, -- Rowan Collins [IMSoP]