Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129522 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 8AAD11A00BC for ; Wed, 3 Dec 2025 08:21:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1764750114; bh=AmXhnFJskKpQ+QfwUM9svzO7baJ055Xib9xIC07TonE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=fHqBTlINP7KDaoEeuknN8Lg0fhaIplIavdRVBgsdSRRa+Vl0qiryfjEptWiVxMF1V bALnc4NeCjzXdcf43Lc/CkjQ7kHIefOnyF1fF8zz9z6HNEYtFq8oPkOjiO7HZHH5zc 6W2ZQua99CGGTaIfde9wIuS9iW2Z7qi6+Wa1QqMdOsMEqS92irCyV1af3iPUPy4SLj QLeU9c3b0N09gWofKHcSSlYHp9FQoErTvwpHhBCvMXp5pyZfbJui+iTMwPKLAyi1l+ hrXHavV/sybfJhAvTfxHX0i7fPt5Net6xPND/JiXP53Q45fyHmHFHS8DyTKALo0qq4 6u9+uegIZJ+Ww== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 478BA18006C for ; Wed, 3 Dec 2025 08:21:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) 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.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-yx1-f50.google.com (mail-yx1-f50.google.com [74.125.224.50]) (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, 3 Dec 2025 08:21:52 +0000 (UTC) Received: by mail-yx1-f50.google.com with SMTP id 956f58d0204a3-640c9c85255so8463727d50.3 for ; Wed, 03 Dec 2025 00:21:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764750107; x=1765354907; 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=NRnCueLWZZsIcrHAUsgsEzxQsix3UZVz1V3rdkrn9YE=; b=cYCElOS7Pwseouf83E9rdL2hYCCyParlkCYif3p/iwTgiJB7ICX7Dle3EG0FSc5s4N dtByGAlPWaf18216jx95hlP9n0bXI4c3YU+WCddOesYClmVpo8vaoBPhgKSMIJ6ycNy4 nAIBfAAqrLWCT4CFTPXK+AdAYM+0fd/B7Ci2mmFKvkcKz1PLgNGvBft6/e1jNS4mT4vS CP8Ukucs2wBPEygysCDYeu0qJI21PA4dw4xJ3o6AVw1IbtT4Ef83NCkKV+dBZi/Rk0rk ZXjl0xWdjvsb0nAKx7pE6MwCFZ13PkVu9kXhX1nA0LpcxYgmizj109dTTa/bc6CCligt hALg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764750107; x=1765354907; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=NRnCueLWZZsIcrHAUsgsEzxQsix3UZVz1V3rdkrn9YE=; b=NWCro46h6J9lurWh4eb3Y23gxTTRanqP+ftkyLEOH1HoE/wFdED/BHuc8aAfehN1nZ QrSzGWQoZKHZZL59Gj65ngLOLQzLoCLzQXSRdckEVuUPphvM35m6N+OEXUmlnrQ2qShE cmoCzGd9XkbP8AD7UkZaANK2+Qd5JeHzUAl+1k1PAKOw5hAf5BlsLPQ+0ap9P21V2rqO uM4hiT5CFjojcDpiM/xgSdOX5imHJGHJWhUUwx/KBbJV2PGtAAoZo3X3bmmVHJm+cdYb IuhY47iUh5GFp4znZehtlGPN46D6HORBdMPuOEO7z7Lc8KD/NV/a6Rg9Zu+qs83A88+V ABug== X-Gm-Message-State: AOJu0YxSXTX++9fWBXLUCulkZ7a5BsIoIpeCdswcXxWqxKxTsUHgOojj YkSv8IcF3MnWn+WV8h1K4qd9iMogSf9rgEFGsoz9TsmI6yKmyD/94SWAK9Y++jX2AUCRlSKIS6h 46QKezomLiJRoAQzre3KpQpes+aODuUejVwt1SHM= X-Gm-Gg: ASbGncvOa2CHGrJNZlkWfs6IAUqt9mLNsTOmSULcmJL0R8xvecDZ6Y+9Wf5bFUttytZ GeIBIbylOD2hGE8PVc73MqG8DXdznSOAK1Oi2VYdlPsRA5D4QuEw/LJoIARPbLqx+SwNNWZgpUp qiW8QLr9nReNjgiSJ14xYZEqvSt83pf9f95/DQOdyn4GaNUyUN4rNKXLXMLir1BmbMOjIMGX+jA Xe3/RLWJIUFZgAn1M9BpHf9J+ea33CRO11bn0mQfQFPhX/Ap4c1nwB9DIFMFOOQKUh30Q== X-Google-Smtp-Source: AGHT+IEoJT8pA4TYmkd9ulF33Fm20hznRpx4wqKYDDoAIoJWWfDGdA6yetcH+0uivPTmG+QD2OFHLmYjhJNPL0yA/u0= X-Received: by 2002:a05:690e:190c:b0:641:718:8a0d with SMTP id 956f58d0204a3-64437044d09mr1100166d50.65.1764750107173; Wed, 03 Dec 2025 00:21:47 -0800 (PST) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 3 Dec 2025 10:21:29 +0200 X-Gm-Features: AWmQ_bmFe3WA2Xhi6sTnW1JrqdfgywpmWWvaEDXYgEwfcW9mjw9S-6yJrNUIrLI Message-ID: Subject: Re: [PHP-DEV] [RFC] Pattern Matching To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="000000000000416735064507e791" From: drealecs@gmail.com (=?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?=) --000000000000416735064507e791 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Dec 2, 2025 at 10:09=E2=80=AFPM Larry Garfield wrote: > > > > 1. There are mentions that any type present in a function parameter > > signature and return value is a valid pattern matching. > > But are there any plans to extend the pattern-matching-syntax to > > parameter types and return values? > > > > Of course, with some restrictions: without variable pinning.And without > > variable binding on return type, but that could work on parameter types= . > > If that's possible or already planned, I think it's worth mentioning it > > in the future scope section. > > See the linked "speculative extensions" document. It's mentioned there, > but it hasn't gone beyond "Larry thinks it would be kinda cool to write > `public int $x is >0`. That's definitely out of scope for now, but I'm > very open to discussing it in the future. > That is not exactly what I meant. Since all types are valid patterns, can't we enlarge the type set to include more things from the pattern set? in future RFCs. Something like this: `function process(Point(x: 3|4, y: $y) $p): ['a' =3D> int, 'b' =3D> float & >0]`. --=20 Alex --000000000000416735064507e791 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Tue, Dec 2, = 2025 at 10:09=E2=80=AFPM Larry Garfield <larry@garfieldtech.com> wrote:


> 1. There are mentions that any type present in a function parameter > signature and return value is a valid pattern matching.
> But are there any plans to extend the pattern-matching-syntax to
> parameter types and return values?
>
> Of course, with some restrictions: without variable pinning.And withou= t
> variable binding on return type, but that could work on parameter type= s.
> If that's possible or already planned, I think it's worth ment= ioning it
> in the future scope section.

See the linked "speculative extensions" document.=C2=A0 It's = mentioned there, but it hasn't gone beyond "Larry thinks it would = be kinda cool to write `public int $x is >0`.=C2=A0 That's definitel= y out of scope for now, but I'm very open to discussing it in the futur= e.
=C2=A0

That is not exactly what I mea= nt.
Since all types are valid patterns, can't we enlarge the = type set to include more things from the pattern set? in future RFCs.
=
Something like this: `function process(Point(x: 3|4, y: $y) $p): ['= ;a' =3D> int, 'b' =3D> float & >0]`.
--=C2=A0
Alex
--000000000000416735064507e791--