Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112566 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 13092 invoked from network); 20 Dec 2020 20:37:26 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 20 Dec 2020 20:37:26 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7B0811804B1 for ; Sun, 20 Dec 2020 12:09:42 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08olkn2093.outbound.protection.outlook.com [40.92.47.93]) (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 ; Sun, 20 Dec 2020 12:09:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TWqtDpDfwHRBNuZvT9oTKqLrBaRIuoshhLIotOZkyhuiqPKcekyTSlfXntTy5mDCoIHx6x/uXWAXmezws9F3VDrglF5Zn4JEWb6n2MgrI+wZORDzxlRSZ02OupcSVuguVhIqRmsjV8xtKX7vlROC3Q7wnHH4/1rU3e8Lf0IwHDp81iHdVpk0IvgK1mlW0HfdQqUfTTzafGdSdwy8ycdUaPsE4MBFyB9m/SIv4xz0T31BlVyDfgFjXinscGZ6pR7lVpUuPthcr022jXgFiKlHOGw82ngNI6JfJBvfM7enJSuJ5HShabrukqSCFEogE1rlwyK2SbO+WRkPl6CZ8z8nzg== 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:X-MS-Exchange-SenderADCheck; bh=1arruyFQA6ZSlqOCymeu2jsCsB/R8VUzHB/kAOdvYyE=; b=af8+F4rq6Z3BtBUrxrOfAHh1FAJEcTcbvGQAEAq8cWG6NMBxck1otx6X++QV9AOkmkCKGRRzCr/AeHLJwYBmsQ8MRWfHvzD9+Oi/yPhfEV1omqp2pczZK4fJC2RjECyBGi7a8oLb+1eTuEOJEs01kg5eZdM4pTP3K6ofdqFfjo5YZVtfb9seSKbELrFulseND1KTYxhRlGgGQJJNGG13/zBIDCJl6DsyT+oWn7db4bi885wcNum2ENiD6A+ZBx5BmgPLQARVCTz1dyLMC99ylO2+GOz7IHajfHrUW2ORxuhefOt/g/3LuB9ATni5rPY32GF4ZzXCM3/RU2al19facQ== 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=1arruyFQA6ZSlqOCymeu2jsCsB/R8VUzHB/kAOdvYyE=; b=rKp2UZThmJ6Re37FbMjQgEHxSww2+dlaF7+uhk3JSKKjdOvr0db0apljfl4Yvg3n+W/JhsGMwTQsB53oTgwKJkjCN5aiQC7q1l9Gk5Ris6v/o8KvVgoQ7roXO49iDDcgHxEfY2kfEmJXV4wnBmGZq9wN8S9EANquwsiNSsfDxXVUnrjaf2Xzw1SQZ9Up3a8TLwTkBoraqHzyRMlGc4qUwRntn34hUeqKnCUVsmcTq9jnjjcqB3pHyFvH9Le3Ks7bULb6makqmoltCiQn1YRM4AA4K9XiKYOW0nCmegctm7r+rAaKWbxoq7Hzywasag82XeMnWBs0PJHFKOhx/IUNTg== Received: from SN1NAM04FT061.eop-NAM04.prod.protection.outlook.com (10.152.88.53) by SN1NAM04HT112.eop-NAM04.prod.protection.outlook.com (10.152.89.188) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3676.25; Sun, 20 Dec 2020 20:09:39 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2a01:111:e400:7e4c::4f) by SN1NAM04FT061.mail.protection.outlook.com (2a01:111:e400:7e4c::457) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3676.25 via Frontend Transport; Sun, 20 Dec 2020 20:09:39 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::b4c4:dc11:5337:821d]) by DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::b4c4:dc11:5337:821d%4]) with mapi id 15.20.3676.033; Sun, 20 Dec 2020 20:09:39 +0000 To: Larry Garfield , php internals Thread-Topic: [PHP-DEV] [RFC] Add is_list(mixed $value): bool to check for list-like arrays Thread-Index: AQHW1m7vogEIYJkiwEyrC80th3/gm6oAOIaAgAAqYHA= Date: Sun, 20 Dec 2020 20:09:39 +0000 Message-ID: References: ,<1b92dea2-667f-4de7-9de9-0aa41f56f81e@www.fastmail.com> In-Reply-To: <1b92dea2-667f-4de7-9de9-0aa41f56f81e@www.fastmail.com> Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:CA31FA6F0E0772D20FAAD7F44159E19FA345020365550FF6BB50260B3A65A5A5;UpperCasedChecksum:B0284D55AC192AB87E0BE52B6177723CA02977BB3570948757CFA72ED4BA7AD7;SizeAsReceived:7183;Count:44 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [bubto6YO8JSH96AaagwOExBll2wLmaHT8P9MyV5Y4dfqY520nJ8YOLR+VyrJBWTg] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: 4b979068-99d9-480f-5a21-08d8a5232eba x-ms-traffictypediagnostic: SN1NAM04HT112: x-ms-exchange-minimumurldomainage: hhvm.com#5237 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: HTnkRrPu9hAMmoDnr8/XBKgMvnKHNmqZfsor9sSu69eu+r7M7dxBY5q65WXBV/z6Z1u9futOKK0ATkomX2X3JBu+YM1HoW3P4cFBlW7DuoVBTCUM7/fz834pPWZGx5ZxdhS58jM7SwPTFBLuUvMjFEXhRGl9i79dsqgc6d5qDsV6yHmEJnuz2WUfu7crCoz4Un5/q5J5B4nH+h7J8OzQ1idrtnwo1xJpG2sCLeA8b8lupU42ytkajk1GJuBAqpV90AN+LA/VxptfF7V0s3rzFXhUjOb7mFP9L1zDZ0mU9/Q= x-ms-exchange-antispam-messagedata: RPVv4ecvGnQv2W6EGXPADy4mn9ith5j5lN5S9YmDwjH67KEbREfhefBse61uMPHYjgr/sYeY8P2DaxdUgYItVMmOMKAnhIT9pTDX12PwvVxa2bwJ4kYSsAOnZUxWP21uNimNRYMQgo/U4ntFURjsCGkcdwLY6fcPKFYJqhRG1tws99w9YxNregJOPBe9SZxTV7V+mTABInTGiC5a+3JIZQ== 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: hotmail.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-AuthSource: SN1NAM04FT061.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 4b979068-99d9-480f-5a21-08d8a5232eba X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Dec 2020 20:09:39.8168 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet 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: SN1NAM04HT112 Subject: Re: [PHP-DEV] [RFC] Add is_list(mixed $value): bool to check for list-like arrays From: tysonandre775@hotmail.com (tyson andre) Hi Larry Garfield,=0A= =0A= > Well, since I'm quoted... :-)=0A= > =0A= > I'm fine with this, but have one question and one correction:=0A= > =0A= > * If we do eventually end up with list/vec types, would the naming here c= onflict at all?=A0 Or would it cause confusion and name collision?=A0 (Inse= rt name bikeshedding here.)=0A= > =0A= > * The last quote, from me, has a small error.=A0 The last sentence should= n't be a bullet point but its own paragraph, after the list is complete.=0A= =0A= Yes, there's definitely the potential for naming conflicts if the type is c= alled `list`=0A= but not if it's called `vec`/`vector`/`varray` similar to https://docs.hhvm= .com/hack/built-in-types/arrays - I'd prefer the latter if there was a viab= le implementation.=0A= I should note that in the discussion section.=0A= =0A= If the type is named `list` instead of `vector` and ends up incompatible wi= th arrays,=0A= there'd need to be an `is_list_type($val)` or `$val is list` =0A= or some other new type check with a less preferable name.=0A= If it's compatible with arrays/lists =0A= (e.g. only checked during property assignment, passing in arguments, and re= turning values), then it wouldn't be an issue.=0A= =0A= - is_array_list() or is_array_and_list() or is_values_array() would avoid s= ome of that ambiguity but would be much more verbose=0A= =0A= Providing objects with APIs similar to the external PECL https://www.php.ne= t/manual/en/class.ds-vector.php and the SPL may be easier to adopt because = it can be polyfilled,=0A= but there's the drawback that there aren't the memory savings from copy-on-= write and that there's the performance overhead of method calls to offsetGe= t(), etc.=0A= =0A= I'd expect the addition of a separate/incompatible vec type to be a massive= undertaking, and possibly unpopular if it splits the language.=0A= In Hack/HHVM, it was practical for users to adopt because HHVM is bundled w= ith a typechecker that checks that the uses=0A= are correct at compile time - because PHP has no bundled type checker, a ne= w type would potentially cause a lot of unintuitive behaviors.=0A= =0A= I fixed the formatting of the quote.=0A= =0A= -- Tyson=