Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127350 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 AD0081A00BC for ; Wed, 14 May 2025 07:09:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1747206440; bh=clkJKDqERkXU/FQSH4rAqzenrcCxObTXoRM+pxF1+yI=; h=References:In-Reply-To:From:Date:Subject:To:From; b=dR6MCy4h/s3KLm9buKMwyttp2jkMh6CPah4jKkKiWwKSOzg7iievc1t6DDuTJcPHE /YfILn8+rmbg1YPP6ejg/VqMhfhK8qYBEMUoAbnB9jpC10r9AVDWn/DsA7/fu72Uu1 WXBWwHVXUFXC35dmDbjfcnTe4Of1uxh0odYpRahbzpGxi5sYFtCxXcLhv6H9O440EH S6wzqjfIb//ovF3zmFmx4FZoYz1FAaFnphxhpyuAS7nTbRbrOaclh9SVS/QzCa+jjI cS0l3JZ2ItZgZqHbv//J1OxMSou1nnWN8jfYmYi4p7A/QWd0MgrdojY6bm0frrvo2i FUbvz+vI3TVUg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A947318006A for ; Wed, 14 May 2025 07:07:19 +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, 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-f171.google.com (mail-yw1-f171.google.com [209.85.128.171]) (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 ; Wed, 14 May 2025 07:07:19 +0000 (UTC) Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-7086dcab64bso61704847b3.1 for ; Wed, 14 May 2025 00:09:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747206570; x=1747811370; darn=lists.php.net; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=clkJKDqERkXU/FQSH4rAqzenrcCxObTXoRM+pxF1+yI=; b=NYXfOA8oGuloDa/K5+Ckcc6sx/qTSdrsMgv061XPYcJMJ4ilyayaTUfjcW+Gl9KuZ8 ExuIvQOB93xdhNeZruGPSD9CTfNXo96RTyu0wMnniPU40dgrAGUBZ+U9QWuLpBi1gHhi G5HvD/Hm/kygq1w96trJBNI38K6waek+05bL02wRKQB89ixJyLZDb3al4lG1n7qXQBPQ N6gf61/lRdOJWFttpZ9ms4wlK5HNIripdMkKBwocN9BOBiGRpJFuk6QtlqEX27oTDAws w2z8JrwLrlzJdWvteFFyC+j9xKeLv64DPiiNd5Pe2k3bRDFD47tCa9jNUoOl6+p8alaO zPGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747206570; x=1747811370; h=content-transfer-encoding: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=clkJKDqERkXU/FQSH4rAqzenrcCxObTXoRM+pxF1+yI=; b=HT7X6ZxXaYr+xnWdF3GynBxHjsviK4gWYS5T9icB7Tg0LpMarlRpV+yl9Z5vYmk5a1 1d1xGdX6aGxMKDw6cjVgv0tMCfc+W3GjCqWPaw20KI3H5nL2hqXrGxmUD/cJiPrquP2B K0631gXM7DELpl/+SWD6evljFwmG5p28hZOCZP0Dmw+HtZz+leJY9scWlYnmKxKQgTLX Li7doneRiIzDbl6ssi8REZpFNDO3QsJpaPsHip8eCRi44rtEE4hIWA3CwsZQoKRU/Urh /tnOphFp7+w4da4izqaIru7cqARVl2A4iuVirTsKY+6RDDEYeSFFwlnjNNcYzUpuLUGp YotA== X-Gm-Message-State: AOJu0YxFvItDhWFZ7tNLJoujMPWPj80EEm8QZl8YH6p4EDzNaJWXRhJF FzCqHgaUmtsd+axKJBY0wbqJyiZoQS6MUGOpy8XS1pvt4CZEKwiBusQZw7beDrreiAJxjgEjjpK p+Bj7YlIj7mqKHTubFIBE5NCgfhcgUEgH2YE= X-Gm-Gg: ASbGncs+KWf7pHDvn3I9Z7q+5wnASPAtw7QjQ6Zk+wV8ZeJNgIopmgYiatXnIOsXnGq dhfDbGjMJ1JwXG1jYRMggB/TLIaOtyD5G217gP89uOUkODTg1reAVBIijaqanQjldLEgCZt3KTf rIBNuuKG8fkQRSn46RifRXnhXE1dEz+dBd X-Google-Smtp-Source: AGHT+IFt8GitLUkoynCtiD6cPli0cjBO0qVao87D85LG9q7fNZgszyG40f+jLoifkhrD26S/P2p00XeyU1qM2jx4YcM= X-Received: by 2002:a05:690c:4b07:b0:705:750e:851 with SMTP id 00721157ae682-70c7f24384amr37143547b3.37.1747206569866; Wed, 14 May 2025 00:09:29 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 14 May 2025 10:09:18 +0300 X-Gm-Features: AX0GCFscxJlZvaMGfn9ZOLTJ0w-btdroHRKjdXkAfwWZ39DuXY3d2TYmz5LIbCA Message-ID: Subject: [PHP-DEV] Re: PHP True Async RFC Stage 3 To: php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: edmond.ht@gmail.com (Edmond Dantes) Hello, everyone. While the code is being developed and changes for the RFC are in progress, I=E2=80=99d like to share a real-world situation. This is one of those cases that once again proves why software design cannot happen without writing real code =E2=80=94 why architecture is impossible without practice. ```php function any(iterable $triggers): Awaitable {} function all(iterable $triggers): Awaitable {} function anyOf(int $count, iterable $triggers): Awaitable {} function captureErrors(Awaitable $awaitable): Awaitable {} ``` In the latest version of the **RFC**, I tried to split the awaitAll function into a separate `all()` function, so it could be combined with await. This solution seemed very elegant to me, as it aligns with the principle of separation of concerns in design. What could go wrong? As I began implementing the concurrent iterator (i.e., refactoring the old code using the new approaches), it became clear that the Awaitable object returned by functions must be able to be awaited multiple times. But that means the iterator may need to maintain complex internal state to correctly pause and resume execution. I became curious about how many edge cases could arise in this situation and... it terrified me. So much for =E2=80=9Celegant design.=E2=80=9D All that glitters is not gold= . It might be possible to find a golden mean between implementation and interface elegance. Have a good day. -- Ed