Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123765 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 qa.php.net (Postfix) with ESMTPS id B1A3E1A009C for ; Sun, 23 Jun 2024 16:26:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719160059; bh=Un7FFxgGKkxrQl7hHGdJ6VOfZ3Z8NSjgaIlDXygbEGw=; h=In-Reply-To:References:Date:From:To:Subject:From; b=g0cu8OBMj/rOQhbm0TLZmZW1O521PXOQUYZ37tzsqQUjrzxlvFVQZx4m6sOchWoSv wGLzE9hl0C/sbX6fmYzSfHGcKfK6CyaAl7RpN8EHEOXzZ796w+si9ErwyFhSUuV35h DW7mXjbnJSbuqP/tfijniqOgbfPd3sEllGpWyvtHTnZtjaE2GpUZ2G73ZUB46WZmPj esE9Z7sMR3978pN7B6W7e/JM6xetfnq7T5aBB3dUNkS+6wemqaO1G2ot0eGt13d5A4 TEcB+75wjVGkRtPE+pdQDQsjLzFHdnAjNfxvDr6PZM26t13G3nvV61HNwLOXofXLUS p3chF/q03xoag== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8721B180587 for ; Sun, 23 Jun 2024 16:27:37 +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.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 fout6-smtp.messagingengine.com (fout6-smtp.messagingengine.com [103.168.172.149]) (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 ; Sun, 23 Jun 2024 16:27:35 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfout.nyi.internal (Postfix) with ESMTP id 6715D13800BE for ; Sun, 23 Jun 2024 12:26:19 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute1.internal (MEProxy); Sun, 23 Jun 2024 12:26:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-type:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1719159979; x= 1719246379; bh=mVXpIW9/pPdDog636NR3YyAmsxmBzIK7Z0iZneXueEQ=; b=Y um8vWG4h3DFX6W141bEzj1vJ8tvi8g5OUszjbp7tgGDZDpGUGMj4iqbFxGHVAZm9 TCUfFdGLf1i7u0MXWuFgBh0LMmr0y+aSgJwdbFvsemF9mN3KylAdKqwLZnCMeZ8a syaD75KAlapmHUXlzdZHAcrNA8gAwnkmlHtrnFp6jUKH7CVPDts1UToA57PPBt+D yveWDIod2NCmNnqc1taJbsdKxt3L9CMLHU8nzzB56e1VjsKGT30rXTgFT4pkLHgH C/aTO+MWhA87/Z3lPPXg9MhMHlwJqrPdT6L5K93NLnK0ceSH+LjjOzdCm8H3axDk SGdfVAqPg0bQqzXSsKMFg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1719159979; x=1719246379; bh=mVXpIW9/pPdDog636NR3YyAmsxmB zIK7Z0iZneXueEQ=; b=FzN/tfEFgDIkgTCQG8vTRi4CWznGxsAhoQviHOFVlpCt 1Tl3Vy2Am93Gff/BusiKI39xE9mPfEAoGCBWozAtpeJqQtWD956HVldKLqcSLQV7 4Rtcj9YkMCgEJGljubGadA6dfPKrNJAopG9Y81Ylvb3LDpdfwsSgY0836djA1d3Y +nce5hbXY4alSps1LMslpoIHEyYqbNKfNNsvpeNsrMjBggMb3wAcUvAdbsWOcdX7 kME40m5G2Vw0dnSW7Ki/uNz+idh2Lx54IpcSd+QYkaXnzis0/V9VIIh9bNHDAbp3 7TBaoxQZLx4WcPTqR3Ih96I0ajvljwrzisuFAIa9qw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfeefledguddtudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepgeelgfekudeivddvteffueejffdthfejieevhefg ffekudevkedtvdelvddvffefnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpe hmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 1C76C1700093; Sun, 23 Jun 2024 12:26:19 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-522-ga39cca1d5-fm-20240610.002-ga39cca1d Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: <7c9e97d3-3d3a-4e91-9eeb-2d460310befa@app.fastmail.com> In-Reply-To: References: <2a6b92eb-d5e9-4a1a-9548-a068ac42ebd2@app.fastmail.com> <02ee8831-43a0-4857-886e-7f54fb42a99d@varteg.nz> Date: Sun, 23 Jun 2024 11:25:58 -0500 To: "php internals" Subject: Re: [PHP-DEV] [Early Feedback] Pattern matching Content-Type: text/plain From: larry@garfieldtech.com ("Larry Garfield") On Thu, Jun 20, 2024, at 8:35 PM, Andreas Hennings wrote: >> Ilija and I have been working on and off on an RFC for pattern matching since the early work on Enumerations. > > I like what I see, a lot! > One quick thought that came to my mind, regarding objects: > Could we check method return values? > > if ($x is Countable { count(): 0 }) ... > if ($p is Point { getX(): 3 }) ... > if ($x is Stringable { __toString(): 'hello' }|'hello') ... > while ($it is Iterator { valid(): true, current(): $value, next(): null }) ... > > Maybe it goes too far. Much to my surprise, Ilija says that's technically possible. However, now that we have property hooks the need for calling a method is far less, so we'd rather not in the interest of simplicity for now. A future-RFC could probably add that if it's really needed, but I don't think most languages support that anyway. (Need to verify.) --Larry Garfield