Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113806 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 67679 invoked from network); 26 Mar 2021 22:04:13 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 26 Mar 2021 22:04:13 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 72AA41804C0 for ; Fri, 26 Mar 2021 15:00:33 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_05,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-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (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 ; Fri, 26 Mar 2021 15:00:32 -0700 (PDT) Received: by mail-ed1-f53.google.com with SMTP id w18so8011233edc.0 for ; Fri, 26 Mar 2021 15:00:32 -0700 (PDT) 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=nzk/gK8SJqcFTg50XnYhWAETB94O/RDW3V73IOYAe0A=; b=BghbES2gVmsGMgscFpPxw4khf9XU9C8tVBm2Ckn3Nf6CywdIglnn0Ph0Er853dCMtF LuGZbz7X7CzpX96zu7MhxgqBE3Ex5opytFgBgrBI+GSZDaGIc89K4j77EHzD0PDvDxCI p1YDGNpJ50S52P9y+dWYZwTP3SYYo+aQMg2fkYYCJv+nuFUW8FvrxVxr4MlChJGAE/D2 NXRJtb2jM0lWdvvmEOtLkqpnJN/j3EMTiZjWrPhXSoqXtkxa40O8We/qLFOhSPZour5D Btpo+4gNXD2TzG0/+LnPr6AiZZLhRF3JKSQYldtEttH6SR5KrmFgF+GghUSGqKcjE0BX UM6g== 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=nzk/gK8SJqcFTg50XnYhWAETB94O/RDW3V73IOYAe0A=; b=Zy3jzMDpEFpHYc9/2sNfPi3mxrpn6WAY9x0QJP5bXgr2UNLPPDBGF20TKzSw+Ed7Jx oI6dPpRdsRWMm0zJDFVCWwhB5cMwAhyG5nOwWpVtSBfLzKlPbaESfKDRnrLXIsMDVDTO ve0GuJ3HkrDVgjC65nBVPefYoNhf7IKBWcmQIrZbDzX9XPCbd2q/p4LNwU5QT6VsJezv KJDvk5Sj/kVL0QjmA5p3FomDLDykGta9Emdia85zh8/gmVpJixECvGJ7A55ou68JVt+P JfjVQvdbtP/nvz7nzc07gMXkna/1Fdffz9F5zp2Gi9Z8LhbEBXC9eEBcSR/na/ZE0/i1 p+6w== X-Gm-Message-State: AOAM531ZB/jAhPXb3pSO6dHglqRooM71t91rIT/CVBl28GJJpqnv7JNL 3ddPnW3P6bqVtZw7Kg4GQFPBZmCf0CQ= X-Google-Smtp-Source: ABdhPJykrI1RrYz5sSVEf/8umz/un+hN3mt/nMdfWIjfsiSR9+0T+hpIEwJpRLZGOoIGzqp/e+0xkw== X-Received: by 2002:a05:6402:b85:: with SMTP id cf5mr17739761edb.248.1616796028980; Fri, 26 Mar 2021 15:00:28 -0700 (PDT) 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 i11sm4400846ejf.76.2021.03.26.15.00.28 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 26 Mar 2021 15:00:28 -0700 (PDT) To: internals@lists.php.net References: Message-ID: <6cfa387a-9f7b-0cb8-2bf0-3856e2f251fb@gmail.com> Date: Fri, 26 Mar 2021 22:00:28 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 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] Making "match" catch exceptions From: rowan.collins@gmail.com (Rowan Tommins) On 26/03/2021 16:45, Olle Härstedt wrote: > That made me think of a recent > extension to OCaml which makes it possible to catch exceptions in a > match-expressions (here's one blog post about it: > https://blog.janestreet.com/pattern-matching-and-exception-handling-unite/). That's an interesting idea. I wonder if it would provide a way to implement the "data-flow" or "expression context" exception handling I was discussing on a different thread recently. Looking at my previous example: try {    $foo = doSomething() + $bar; } catch ( SomeException $e ) {    $foo = $bar; } Would become something like this: $foo = match($temp = doSomething()) {    exception SomeException => 0,    default => $temp } + $bar; Hm, that's not the most elegant; even if we could avoid the $temp assignment, the "default to myself" seems superfluous for this use case. I can definitely see the feature having its use cases, though, was just kicking this around as a thought experiment. Regards, -- Rowan Tommins [IMSoP]