Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113393 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 25417 invoked from network); 4 Mar 2021 22:14:15 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 4 Mar 2021 22:14:15 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2FE091804D0 for ; Thu, 4 Mar 2021 14:05:06 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 4 Mar 2021 14:05:05 -0800 (PST) Received: by mail-wm1-f54.google.com with SMTP id m1so11125407wml.2 for ; Thu, 04 Mar 2021 14:05:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=cjCGhRO+JEzghRUxX0cnUhLWAP2NDRIK+dri6x0AaYI=; b=ujGrAknrkjJPEoFaiqLJ6Z0YfDhRzVi+NwOfg3EX4S+hHAU/sqE1q1QlopKd7AvyDH TbSxXJH6PydEtqm1ibf5cU2EvTc5epskZyxoy9rotIzXkPhkeCiT9AzJ6ZCT+2P3t6kT wLzEhygYvvfanRULcLrM6/X18Gl+d7R672pwCQipVNU40l+mlSGw7GtYErIgif3SOKWX y97hUB78DFsZZ77xmMtvUgKa1DlJDBuPSDCLI109466rdnuLdcnb63m9d+JIuj18a+/G N4fPthqeUP9FLq0gOn5pw7EWbR8GtO/uQ/Q7tR8HUhgYST7xXp8yv3d2X2HCe154+Qbh sd9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=cjCGhRO+JEzghRUxX0cnUhLWAP2NDRIK+dri6x0AaYI=; b=IgJWVvzIdibRMnoYbFTCAudlUuH0fMTlm+3tafNxxme6pCkD86C7oPJqzlRgpJ7NcS yD3/Bt6aoqE4jywqY/63gwRqBKGmzbf6ePVzlgz24XnD4Y4yQFVy2PGwIaQC3TPSj5Xl bXFVZIQMktQRp7gW3AuljmMqi+VDl0yqBZrWsFT+9dUq3AEX+dGh3VZCJnAyXa2YzWA4 vaTdLP641XOYluQLKXy5vU6vhjer98hgurhla3M+h2rEmvJ3cWF1VU5SsgZNOgqI/0Ez fo3FWQKnCXWCydnAC3o0vM9UVWT1OfyFVJX0819LbC7QOPqYZheJxr/pqzHiRQt+R7WB hnSw== X-Gm-Message-State: AOAM530eI9zQUePstVPtTqp5K8zaLLE3rbp/5xicnSCW7/Tsoos6GTr1 41MaKc3ypUCXmNIj9c0+k7SySE98hFo= X-Google-Smtp-Source: ABdhPJwAIIkQ1EsqDfB/QVQkIE9hU/e6JBtzZf5oIQGYbSDrYUbjBMAQDf3YJBRfMyMZTQoOYMFcIw== X-Received: by 2002:a7b:c188:: with SMTP id y8mr5727394wmi.76.1614895502448; Thu, 04 Mar 2021 14:05:02 -0800 (PST) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id 4sm1458858wma.0.2021.03.04.14.05.01 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 04 Mar 2021 14:05:01 -0800 (PST) To: internals@lists.php.net References: Message-ID: Date: Thu, 4 Mar 2021 22:05:01 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [PHP-DEV] [RFC] Extend error control operator to suppress exceptions From: rowan.collins@gmail.com (Rowan Tommins) On 04/03/2021 14:08, G. P. B. wrote: > This new RFC which I'm proposing is to extend the capability of the error > control operator @ to not just suppress diagnostic messages but also > exceptions. > It can currently be found on GitHub: [1] > https://github.com/Girgias/error-control-operator-exceptions-rfc Hi George, This is a really creative approach to this thorny problem, and I think I like it, although I'm still working through the implications in my head. One thing I'd like to call out is that this could be useful in its own right, outside of migration strategies. One of the big downsides of exceptions is that they always cause control to jump somewhere else, even when you'd rather they didn't. Joe Duffy in an interesting blog post [1] about error handling strategies refers to it as "control-flow rather than dataflow". For instance, if you start with this: $foo = doSomething() + $bar; If doSomething() throws an exception, and you want to default to just $bar, you have to write this: try {    $foo = doSomething() + $bar; } catch ( SomeException $e ) {    $foo = $bar; } What you really want is to catch the exception, but not break the flow. With this proposal you could: $foo = ( @doSomething() ?? 0 ) + $offset; Which leads me to suggest changing this: > As such @<\Throwable>expression and @expression are identical. To this: > When a class list is given, the operator will not suppress raised errors (E_WARNING, E_NOTICE, etc).  So @<\Throwable>expression will suppress all possible Exceptions, it does not have the same behaviour as @expression. This makes the operator useful even in situations where you want normal error handling behaviour (e.g. logging) for Warnings and Notices, but want to force an exception back into "dataflow style". [1] http://joeduffyblog.com/2016/02/07/the-error-model/ Regards, -- Rowan Tommins [IMSoP]