Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113807 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 72436 invoked from network); 26 Mar 2021 23:01:52 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 26 Mar 2021 23:01:52 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5B0571804B7 for ; Fri, 26 Mar 2021 15:58:12 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, 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-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (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:58:11 -0700 (PDT) Received: by mail-lj1-f180.google.com with SMTP id z8so9097290ljm.12 for ; Fri, 26 Mar 2021 15:58:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=B08FX2gbHXnTqNNQU8+5cy/F408ovFroUzyDJdz4i0w=; b=CGgV6dAR0uzO6LMnFYW6U/Pi/rd0e7td94YFW+YObh7VnkAPTU7t2mzayn2OUEqz5D +l5PDBus+xB4CLkw9/LiFXZRcAzLjGZ0s2LijmXBo2IVf5NSdvO1CenOX6jmlnalypw4 ByUXjWgghY2s0rhiFxzF9wjI1Dn5newSS8cY59oJIHBV6BaYzDAkBQ8kO6f4nrykTFsR IyNMNBl87cVjLSmPb0/lWwfvWElB4ui4EP/6d+v3rF2Ma4OkJrFj0pJxBCSg4bDS4xIh JIn9CkuWU9oDFuq+uI7Pz9MvWWWondCnldB/usJNrV7xUve2eWgmnrx7DioRNerxuwDm Chyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=B08FX2gbHXnTqNNQU8+5cy/F408ovFroUzyDJdz4i0w=; b=DyulTMp/nOY1U/OkejGxXJrEv3sKL1JA8owUaJEERZTBkXdpKnewyB1cbdhtiisXru HFAA45cI2ilWa8osPQoQvmZ2CG8/ehqvPOSs7I7j5WvOCKeEhgAUtBcaWYtPfOo2bHae NfRTyZhN8TNUuonOIXAX9NbrPDXY6u52eJgtmS9aEcnTUbPPXVStbu3ErL73eF/TKenf A+nl7nXZKF17rGyyLNYmGsfgILp6szAOurGrN9j+1JqmTHC+EXf9r1XxuMjLx9Zfp7/D ojtchsCSAPAFshIr/D94V1Tew2+3Hv+O4GTYH6CRJZsdJxavYcpR8QKAFtL+MMrTmiYU ypqA== X-Gm-Message-State: AOAM532PMS2w+K9Cna2467Yf8qpyjgHO3vFBCKXosieKQa5NH6dtZKLO KLDzZcniwSM+wudK0ggBuVERUfXUcvQ8CGkkWNo= X-Google-Smtp-Source: ABdhPJwTaYSny40+DxE2b3Pr5m9XDDgSbcPw+g4CqQC1MSxNkAB0SQORerTjJOA9KFyWLAyjTymsSL9l9LsCSfT47lw= X-Received: by 2002:a2e:7a13:: with SMTP id v19mr10329843ljc.175.1616799490003; Fri, 26 Mar 2021 15:58:10 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ab3:5f8f:0:0:0:0:0 with HTTP; Fri, 26 Mar 2021 15:58:09 -0700 (PDT) In-Reply-To: <6cfa387a-9f7b-0cb8-2bf0-3856e2f251fb@gmail.com> References: <6cfa387a-9f7b-0cb8-2bf0-3856e2f251fb@gmail.com> Date: Fri, 26 Mar 2021 23:58:09 +0100 Message-ID: To: Rowan Tommins Cc: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Making "match" catch exceptions From: olleharstedt@gmail.com (=?UTF-8?Q?Olle_H=C3=A4rstedt?=) 2021-03-26 23:00 GMT+01:00, Rowan Tommins : > On 26/03/2021 16:45, Olle H=C3=A4rstedt 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-unit= e/). > > > 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 =3D doSomething() + $bar; > } > catch ( SomeException $e ) { > $foo =3D $bar; > } > > Would become something like this: > > $foo =3D match($temp =3D doSomething()) { > exception SomeException =3D> 0, > default =3D> $temp > } + $bar; You can't catch the value of $temp in the match-case? $foo =3D $bar + match (doSomething()) { $temp =3D> $temp, exception SomeException =3D> 0 }; Olle