Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127225 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id ACDCD1A00BC for ; Mon, 28 Apr 2025 16:28:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1745857565; bh=JIV3yZjXiceIS2hU/NhGnAQf5tCLWFw+nt78Zt0rEzs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=W6NPxVAmnnUt0GKli42FSkmg1bhQAQpdGKwPDaVQMIf+YkIL/CnaA1anYo968UkVx utLRv53G8dMwhALie/yH0bCzgf7d/bpydCekP2RcBD8GS7b3EZPYKt/JI6S2GLJTP4 dSMDxveWdu6NLe8k7glqf8Ve69/Djcccs5sNBqPJjp8mqaVFlIiDUENQxAWxzuJQ54 i9TcuiFMe5IE6VLYhEIUwDJusVwKJJ+iwFRbVmYw/VUwxZDDYO4HcaUDba4GSrXyWp 0ei8Ar9uKCJNTNW4zD6vrAV4yqBBf1wfbKrYI0lzTXgqkFra1sljlGUSwFLGZKUiV7 6Bm12Wqt+yQDA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 98DEC180080 for ; Mon, 28 Apr 2025 16:26:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.175]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 28 Apr 2025 16:26:04 +0000 (UTC) Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-7053f85f059so45913097b3.2 for ; Mon, 28 Apr 2025 09:28:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745857701; x=1746462501; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=5/2LdH4I9PXNgZ+FEIhGqPEXZD/X6WneI/29vi6wsKA=; b=VOdwVBH3DLmXNyZt0h4Ys6xFtd4U2+uZdDf7V2yHwV6TR2Ltpqg5SVAGWp4o/FsTj/ 4P23CH5Q2Q4rpjmWm4O5cMbNaJnbKFqO8IiB80PrUZ/Fpe5qxRppoZtZhKR23lZprSz9 CG7IH9RXZSBKogvZesVWwx3d0MgkOI3OjfKlj5IQmgZjVSCqZWuWUFCO7cwLOB8StNjz JegsWjfPL8sZopBHawx5wX5OdsOGdvu1HyOxOBc3uWu2FOcgmtYirUJwR50/Oa5/ozyj aCXA8PWxoy3jZ3Drjj4MwXlCzymYJnp0OY4LWQCt+wwXobhGfTFb8jIRDYtyargHpSE9 WmXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745857701; x=1746462501; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5/2LdH4I9PXNgZ+FEIhGqPEXZD/X6WneI/29vi6wsKA=; b=ET5IuduDCPUGf+MQQd07UnMP+oALOYtmsidkxHr3+HuICCK5HXsDMYnetmpPAP5RD2 Nx6RCAn9pEHSDRAbyxUkTqKhtY1/XbTmITOTrHOrpGEB8DxE3hBDj+TGrF+5hqzyfeB1 r/SvSgSIUTezdnxUIl34vV9tFMG4gVcMptM89bcJPm8pvgRZ5TjhuNc5PVKslxnje9KN bDiK0rS8mMaFJoLGfj+XQ/qnthRD8K9REOGvcfa4wHAJWmD2/c9gHSaSyPBENVfQ9OH/ Ww5+r9Zo5DQ07xcASTxMFa3beZ3193xarzUxiHSHglymzrWfKUlqS7L8LXDuieOI6bmH CapQ== X-Gm-Message-State: AOJu0YyjG4N1GgOf+w5yKhzMmBXAsuZE+UFRN+X0J3CHv6Z1kLXXhrFX Lj+gyy5qBBR3WUaPRfckb1gfE720ix06xl4bmaXVGIRARjC9EgAP5XnZDK55ThpCPaGihT1tgVx FcrLrsKeHDvqnq4MIg9kmj5VN/pFIiRT6qUo= X-Gm-Gg: ASbGnctEJxwB0mp4hgyBgwGErAdQaTRGujkjtwyCZozEy7ATkP7fqKe2tet6V+UY5NE eh5rvb5aycBNGbBscn3aOBUOaxJ9F/mL/zWcLs88Z9b6afGnxb75m6TuPIxkPuVF6QxJghNZV1Y ipIytO5nEfU5U4bmiFQPhYsg== X-Google-Smtp-Source: AGHT+IECIerPL0+ZXHR+KR4L66l2gnAesAikkHzII8hR29StSJGlaCLN/cDGt7aInLvXWtUcolLb9iD3aY9Ebs4AUrM= X-Received: by 2002:a05:690c:46c1:b0:702:627c:94ec with SMTP id 00721157ae682-7089977a946mr5861967b3.35.1745857700595; Mon, 28 Apr 2025 09:28:20 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <39597a9c-6854-40c6-a529-32b2b178cb27@app.fastmail.com> <150fb4df-47a4-4ab3-8edb-13e446b122cc@app.fastmail.com> In-Reply-To: <150fb4df-47a4-4ab3-8edb-13e446b122cc@app.fastmail.com> Date: Mon, 28 Apr 2025 19:28:09 +0300 X-Gm-Features: ATxdqUHQkBUSy9AuR4mhS1aT5gNOd2qarV04qdMH9CHWNgdCFvL88P0_eLm14Xg Message-ID: Subject: Re: [PHP-DEV] Concept: Lightweight error channels To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="00000000000012945b0633d92c9b" From: edmond.ht@gmail.com (Edmond Dantes) --00000000000012945b0633d92c9b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > I have already demonstrated how it can be solved without generics. Multiple response channels from a function already exist: Normal returns and exceptions. Exceptions as currently designed are just very poorly suited to the problem space I am describing. If another error channel is introduced, PHP would end up with *two error channels*. This is harder to understand than the Normal returns + Exception channels + Something new. It seems to me that this creates a bigger problem than the one it is trying to solve. Is it possible to avoid creating two error channels and instead design an alternative handling method that would eliminate the drawbacks of the first approach? If the performance issue is solved, are the other two problems really worth such changes? For example, if we follow the philosophy of RESULT, we can say that there are two types of exception handling cases: 1. Suppressing an exception immediately at the first level of function call= . 2. Stack unwinding. For example, the expression: ```php function someFunction(): string raises SomeException { throw SomeException() } // The backtrace is not generated: $res =3D try someFunction() catch (SomeException) null; // The backtrace is generated when throw $err executed. $res =3D try someFunction() catch ($err) {throw $err}; // The backtrace is generated $res =3D someFunction(); ``` This kind of behavior doesn=E2=80=99t break BC, right? At the same time, i= t allows improving PHP performance and adding contracts. --00000000000012945b0633d92c9b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
>=C2=A0 I have already demonstrated how it can be solve= d without generics.=C2=A0 Multiple response channels from a function alread= y exist: Normal returns and exceptions.=C2=A0 Exceptions as currently desig= ned are just very poorly suited to the problem space I am describing.
<= br>
If another error channel is introduced, PHP would end up with= two error channels.
This is harder to understand than the Normal returns + Exception channels += Something new.=C2=A0=C2=A0

It seems to me that th= is creates a bigger problem than the one it is trying to solve.=C2=A0=C2=A0=

Is it possible to avoid creating two error channe= ls and instead design an alternative handling method that would eliminate t= he drawbacks of the first approach?=C2=A0=C2=A0

If= the performance issue is solved, are the other two problems really worth s= uch changes?=C2=A0=C2=A0

For example, if we follow= the philosophy of RESULT<X>, we can say that there are = two types of exception handling cases:
  1. Suppressing an exception immediately at the first level= of function call.

  2. Stack unwinding.

For example, the expression:

```php

function = someFunction(): string=C2=A0raises=C2=A0 SomeException=C2=A0=C2=A0=C2=A0= {

=C2=A0 = =C2=A0 throw=C2=A0 SomeException()
}

//=C2=A0 The backtrace is not generated:=C2=A0

$res =3D try someFunction() catch (SomeException) null= ;

//=C2=A0= The backtrace is generated when throw=C2=A0$err executed.

$res =3D try someFunction()= catch ($err) {throw $err};

//=C2=A0The backtrace is generated

$res =3D someFunction();<= /p>

```

This kind of behavior doe= sn=E2=80=99t break BC, right?=C2=A0 At the same time, it allows improving PHP performance and adding contracts.

--00000000000012945b0633d92c9b--