Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116053 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 20409 invoked from network); 17 Sep 2021 02:53:44 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Sep 2021 02:53:44 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9A6EB1804E3 for ; Thu, 16 Sep 2021 20:33:36 -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=-1.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_HOTMAIL_RCVD2, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8075 40.80.0.0/12 X-Spam-Virus: No X-Envelope-From: Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10olkn2105.outbound.protection.outlook.com [40.92.42.105]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 16 Sep 2021 20:33:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gPYB9ZdNmXOBfdMy49c9KF4SWJfzy3RxLjAgQhIKxCcAK0flBSGjfnFeNbIZ65EEcHrDy/jFCARn4vTNDU+0S64Vbt/HntN/uTxoyOISEpUFepgWQkpmmK9TvAMb3RqCCikHooxMNXwTutFtOGk6rC4jKKjFhbqZqO599cGowB/crgpJUO8S+iCmgwRhdi26oZ59u8SjOTQwqU4+Ol5bJitUitKN7LzVuD9VOT+zwInLNeYaPwvuZ8sazCezxlZHkho2OZevRPTxBYCyNxR8EDFCmGuWdNBhtk/2DPOpT+ubuUlE394thZ4At+hAJ00tLBWw98ABvTEahfpGTqOKzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=RHOy/8qPWmmtM7AdzEy9t2inDZh8V2EnkjStLyaQA6c=; b=P7caul5Bxzm0q2qenS6Gw8UWvrmlEdbze10Ukv3RvjlhUNEzHxQj01rKpSJGnSNKti15gfrTWHmTOkytPdvRxqlJ47azLYUzGN8OyS7HVYjLTh9trOHJx/JSoY1ccVrZpHA1S249hjT+83/FhwdcxCEiqmPtRE3uawt/s1fKCKBnZv7LPXMTlNh8mkoNs5ZyCfRINd4wNtx0mbKgPf+dVpb7f/ITGWQ7PBUF2Xa4oElG3bzJrPZCCaJ3F2O4eKYTVgt9AiaHJNpB562HXskl3iJFwAeOEk9NE4YOsVCZDHsjE4C37b0I1BKz6XJkBqH2LqDMBnyFNS46a2SE+gIL4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RHOy/8qPWmmtM7AdzEy9t2inDZh8V2EnkjStLyaQA6c=; b=de2tQl4PC26dzjvPer/cZPMFvTBZIHuIAgjl4PA9K6AFO5u2hv1rbKK+QemwnOD+gsxYY4u2/We55tZay+nSnOw1rQSPm/oaSYlTUH2Oj30tjgxUed+G6rRV52pFdMtkcSSU+k42ZptsQ/A1tahUIkByCMdMusy14cNn8zRTqI3mJGmOuHBQpixdtqJetKuYwDA2kTnZtLuWYb3c4D+yEk7TfLM7ZrEYEtuLXzraOebeLcKiHjPGQZzRhsd7JdlNOvlNZIlZRE2htmg2zzkfutzbDfDYP3LQonzC6m7b1qcU14Hj1tC20fpCA3Fy/KH725Gkoi3FUFOY0r0z6BWQSQ== Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2603:10b6:5:1cf::26) by DM5PR07MB3178.namprd07.prod.outlook.com (2603:10b6:3:de::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.16; Fri, 17 Sep 2021 03:33:34 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::7181:60db:c4d2:835]) by DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::7181:60db:c4d2:835%7]) with mapi id 15.20.4523.016; Fri, 17 Sep 2021 03:33:34 +0000 To: "internals@lists.php.net" Thread-Topic: [PHP-DEV] RFC: Add `final class Vector` to PHP Thread-Index: AQHXq2Dr5ROExEhu802SAlX6zd1M+6unhrKAgAAIYYw= Date: Fri, 17 Sep 2021 03:33:34 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: suggested_attachment_session_id: cc6e2d19-6ab4-43f4-2c81-97ca924e4fe3 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [c0JAT1endA9tYHF2r2K7NTjIW0Y/x7oWwL9AIWvFului5TKaH0bQRKTvpXHA8J1LI+61iAm4UWw=] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 860c206d-a2a7-4088-1e7c-08d9798bedaa x-ms-traffictypediagnostic: DM5PR07MB3178: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: O3FZWryqxr/+GbUdsTxkzmWXHukZih1Y216oWk9D5Haesp7uHXF4gaxAekQXHTXQGu5gOCwT7BarcXthWqYmHwTbl/rRcRlrZOax2v7W3ucoyuu/GHDhAzD7U8coSNvhBSmYIifAmpUzy4L5AWmoFC9ahYEDt088xkzCCubb1jkl7mMbUxoegfshAd6gYdGANGyaP10e9rZ6NZZ/XDa4oXoqvLzwhRvzv6i3C9DmcNpudSs/rSRD+S7HqbmEgz3w5BlYpx8EJNXoKPY6mvqlQlrLrGlpgh8eQNvP0L/phyYCxWoTuDidiYpFEXc7f/vf+8GSlUwdbJ2OcVn4kwTfVtso3gVw8PJyU3ljBW3MpyC1NKFKKLQgAcuCh6b3fyO8VIk3YTmrqRqlw7svTDpc6USlR6BP5B9XJ2kBouz2szhz5HQV8QU1fvEwFv/BvaMhUjh8uwE1WZ5uDHKb0LOKsVEDkz31Q3nuryNeX0iOFwo= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: Ji+cyOzx8D7G1C2tAlYM/oQY8/ovnM8rpa1J+poq+bNNSz+C2iKKELLzDJEoMjBnl5cW7d2EAKilXEqaG1/pev3mTHQZw2Y8fjhrxcKCtDbF6nAtQV0oapqHx6jqvxGVHkBc8iIeD6wtK2lk0mn1W/7PsfaJLk8/tZ5ge+q/9zpJZQpRP6wToCGRJGfJBjxxWexgkhe6BqlCrF3uRvZfzg== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-3174-20-msonline-outlook-35401.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR07MB6618.namprd07.prod.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 860c206d-a2a7-4088-1e7c-08d9798bedaa X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2021 03:33:34.4030 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR07MB3178 Subject: Re: [PHP-DEV] RFC: Add `final class Vector` to PHP From: tysonandre775@hotmail.com (tyson andre) Hi Levi Morrison,=0A= =0A= > I'm okay with a final Vector class in general. I don't love the=0A= > proposed API but don't hate it either. Feedback on that at the end.=0A= > =0A= > What I would _love_ is a `vec` type from hacklang, which is similar to=0A= > this but pass-by-value, copy-on-write like an array. Of course, this=0A= > would require engine work and I understand it isn't as simple to add.=0A= =0A= Yeah, as mentioned in https://wiki.php.net/rfc/vector#adding_a_native_type_= instead_is_vec , it would require a massive amount of work.=0A= =0A= - A standard library for dealing with `vec`, filtering it, etc=0A= - Userland libraries and PECLs would need to deal with a third complex type= different from array/object that probably couldn't be implicitly =0A= - Extensive familiarity with opcache and the JIT for x86 and other platform= s beyond what I have=0A= - Willingness to do that with the uncertainty the final implementation woul= d get 2/3 votes with backwards compatibility objections, etc.=0A= =0A= > Feedback on API:=0A= > =0A= > -=A0 `indexOf` returning `false` instead of `null` when it cannot be=0A= > found. If we are keeping this method (which I don't like, because=0A= > there's no comparator), please return `null` instead of false. The=0A= > language has facilities for working with null like `??`, so please=0A= > prefer that when it isn't needed for BC (like this, this is a new=0A= > API).=0A= =0A= I hadn't thought about that - that seems reasonable since I don't remember = anything else adding indexOf as a method name.=0A= =0A= > - `contains` also doesn't have a comparator.=0A= =0A= I was considering proposing `->any(callable)` and `->all(callable)` extensi= ons if this passed.=0A= I'm not quite sure what you mean by a comparator for contains. There'd have= to be a way to check if a raw closure is contained.=0A= =0A= > -=A0 Similarly but less strongly, I don't like the filter callable=0A= > returning `mixed` -- please just make it `bool`.=0A= =0A= The filter callable is something that would be passed into the filter funct= ion. The return value would be checked for truthiness.=0A= The phpdoc in the documentation could be changed, but that wouldn't change = the implementation.=0A= =0A= > - I don't know what `setSize(int $size)` does. What does it do if the=0A= > current size is less than `$size`? What about if its current size is=0A= > greater? I suspect this is about capacity, not size, but without docs=0A= > I am just guessing.=0A= =0A= It's the same behavior as https://www.php.net/manual/en/splfixedarray.setsi= ze.php . It's about size, not capacity.=0A= =0A= > Change the size of an array to the new size of size.=0A= > If size is less than the current array size, any values after the new siz= e will be discarded.=0A= > If size is greater than the current array size, the array will be padded = with null values.=0A= =0A= I'd planned to add phpdoc documentation and examples before starting a vote= to document the behavior and thrown exceptions of the proposed methods.=0A= =0A= Thanks,=0A= Tyson=