Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116123 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 12485 invoked from network); 22 Sep 2021 03:22:06 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 22 Sep 2021 03:22:06 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B8ECE1804CF for ; Tue, 21 Sep 2021 21:03:13 -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 NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12olkn2022.outbound.protection.outlook.com [40.92.21.22]) (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 ; Tue, 21 Sep 2021 21:03:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fbRFN2Gz+kxr8A9MTzxt39WZdL8+VC/xmW9i85OX37fXX2u0ZQgB7b9sGUwtXV7NM+e44Bbt1Busst3lpsfvVyFCWA4YvifiynkLWaz+xJVOF/VOchtzsJd4zX4QFcIsCAbMzHx9i/puchMeSJJz8X+vtcQ5Nbksi5GhKrQy69RW6Jz2sWLehxQJ19e4B2toldOW95x/c7nzKnWylk6f8tterog++FN29JFm5nZxzhNzlLyiRwd+klTAMAqLPdM2MpuQnS1spyHqZKgkq40qw/E/5FmplfzxvPhVxRmJacDlpw0LLWpfjufuHR1ScVuJjeKux4i0JVZi6kYzobH7tw== 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=1iJTRarHB6aql2RnaeKKfFUT1XY2cjiAP1DOe0+DcBQ=; b=ibZGXDrkIn/QKt549HLr8P3kTP1vUoWLCGh8/dNuXjGzZRMaKA4Eh2hACjBX77XseEhB4heN3YRZoWOAny6FcGprz3ZJ/KiC7eEgGgcNlsWEeb3wm97XQ47M1mrvaxQqJ4YnOBq0vb/Hf7mdp0saMzvZ8ecrtFETz2qnOhsSaOdOVfrDuxPea4EsG0Kmq/VyROMxQUpDwNEmXxtl/UM9/yjEO2qPjL8TD8RCIlztCmjwR9EPQXSuE63mnqG9Zvszw1CiSMXCa8Fg8SZjOw+esV2SFJj4EWwiVT5EaknALwG4Xw5s4SFl3kcuWP+fcRhMsc4hpgwvYiB7/MdLETZ8Ow== 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=1iJTRarHB6aql2RnaeKKfFUT1XY2cjiAP1DOe0+DcBQ=; b=oQvYes2JhLbr/DV1Mnp1icpF80FVTzhd9ZSNmmxppaPxqC/wUuiqGqSFMJY+BNFYVNl8jNTh0pRLav3Y77/SkSrMz8TO4R+8pY9cLu/HAbMJ3h+LSKzjTQtXzaGXWrI1nUiO9Pvje4oanOqI6fPmLpMIbwvV4LkSNG3OsQC4VPZCYzM70EZkJkOzJYJ794tmxrWNGLZDZuLdxa2zEv9XC5dCU5c8TlVW0ez0YxluH3ky7Lm07GR6kNwPHj4uT8IG3J6JNgw9Hf59pd53exBcAwXVZYZln2pOHYswNjWGEo8Y9UN7hFvG3qe3y12NkabcilMqwKz2mfrKPgsVNBfsUw== Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2603:10b6:5:1cf::26) by DM6PR07MB5290.namprd07.prod.outlook.com (2603:10b6:5:4e::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Wed, 22 Sep 2021 04:03:12 +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.4544.013; Wed, 22 Sep 2021 04:03:12 +0000 To: "internals@lists.php.net" Thread-Topic: [PHP-DEV] Adding `final class Deque` to PHP Thread-Index: AQHXraUxaK1dZ0niuECOJlLUpHNcpaut5O0AgAA5JgCAAJnxgIAABFYAgAAl9YCAABrsgIAATpehgAAZnICAAAlQtg== Date: Wed, 22 Sep 2021 04:03:11 +0000 Message-ID: References: <67BFE5C6-3C3F-4309-97A2-14CA0D8C3B3B@newclarity.net> <7BEE0406-3CAE-4E83-A196-F9F608BE8D17@newclarity.net> 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: 8735f729-f291-0dd6-e5d5-6aa452d7934e x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [uRRISN44Iv1DtXqwrqMGszSmaGcX7QtxShQp4h437vgDdhfFwm7r3D293rSVd5ctKKvYqN8n1DA=] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 96a73807-dfa1-4088-b768-08d97d7de547 x-ms-traffictypediagnostic: DM6PR07MB5290: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: j1HL+o98kij+D62luuK8plb7w0Uu5PA/S+D1LBPoihmz4gv5O4ZELCnTVIZkCOq+E9YMXYJh6giigp95MBcpO2odj+L6KMdhufgrAne0gO7ar1b0AYB37ae5Ee2D9biX9ZGE9BRrc2nOzzGahshTvc+WNIIkfDSkCeDNzeEP5WiOm2pU/bX+mlqH3y30xfdwXoaNM118yywtA06KJf18XPTdBrS/ACd7c9d5OSUIWrhUD2TJ/HQ/vB3cSo7Y6EFj371OFQj8RZ7qI2KDKxKenbh7LEKWYewrRc1mh+FhNQUoXn8IpP8DtLrSb0oF67B5DzrjRAZkFguEFlGaBbskxx1sMZMR+rN8ENXMfjvN4gniSGMwaju9yy8rhMv8fM/xwOs+hBBeNLLVTVPG9J0teKBxiq2qgZ1xAjOwv3FXN0V1xrm1xCqtoiX+fldWm2D3josPZNxmclXCb/4vrQX4DlYYmiHGEF46FGlR9otmJzM= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: AslY8yno3CkdOON98mvyrBKIHzXbIfzuvU1yg/wbxp5fTW+DhvTQ37fUMyJildEGQgJ7d6DtfYtEmb2ky8NKnE+uDqfFIveDnJBNSbXLhMtiKYd+I9UfUTHc8GTAn1LBtqlHQhCMUHJHZv/LyYsppPuutnRnhx9CVlgp3ioLDmaD+6wlbtCMWxt+EuuLAHj+cGSkTg61gu13w4McDbA+CQ== 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: 96a73807-dfa1-4088-b768-08d97d7de547 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Sep 2021 04:03:11.9762 (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: DM6PR07MB5290 Subject: Re: [PHP-DEV] Adding `final class Deque` to PHP From: tysonandre775@hotmail.com (tyson andre) Hi Levi Morrison,=0A= =0A= > > "Maximum size" shouldn't be an issue for `Deque` specifically, it's a `= size_t`. It isn't an issue for SplFixedArray and ArrayObject.=0A= > > (or for=0A= > > PHP would just encounter a fatal error due to either=0A= > =0A= > You wrote a lot, but unfortunately it was based on a misunderstanding.=0A= > In some languages you can set the maximum allowed number of items a=0A= > specific Deque can hold. For example (pseudo-code):=0A= > =0A= > =A0=A0=A0 let deque =3D new Deque(max_capacity: 3)=0A= > =A0=A0=A0 deque.push_back(1)=0A= > =A0=A0=A0 deque.push_back(2)=0A= > =A0=A0=A0 deque.push_back(3) # okay, it's now full=0A= > =0A= > =A0=A0=A0 deque.push_back(4) # !=0A= > =0A= > In this condition, they either error or remove the earliest.=0A= > =0A= > It's okay if the proposed Deque doesn't add this capability, but it's=0A= > the only remaining major functionality which some languages have but=0A= > not the others; it should at least be discussed, I think.=0A= =0A= Oh, I hadn't remembered seeing that before. That makes sense.=0A= All of the implementations I'd remembered were unlimited.=0A= (https://cplusplus.com/reference/deque/deque/max_size/ was a system limit, = for example)=0A= =0A= I can't think of a common use case for that in php.=0A= If there was one, though, I strongly believe it shouldn't be the same class= (and shouldn't be a subclass),=0A= in order to ensure the behavior of push or other operations remains easy to= reason about.=0A= This can be done in userland as a userland class.=0A= =0A= - (e.g. with a Deque instance property and runtime `count() < $this->maxCap= acity` checks,=0A= to choose their own desired return value or Throwable subclass (or manual= array and circular buffer in PHP)=0A= =0A= Thanks,=0A= Tyson=0A=