Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109767 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 68278 invoked from network); 22 Apr 2020 01:46:58 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 22 Apr 2020 01:46:58 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B98081804CB for ; Tue, 21 Apr 2020 17:18:30 -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.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8075 40.64.0.0/10 X-Spam-Virus: No X-Envelope-From: Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11olkn2039.outbound.protection.outlook.com [40.92.19.39]) (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 Apr 2020 17:18:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NbSjWoljsZ+mwUeBcEtvPbLFmBZq8XFR4lqhqKy3GeRaXBLxPNC1Km0qDeLGA1BNGgwwZQDbQxrZBMo6JJr8MrXUfpsxp5IrhfVQsFJlieVqGsDkP3Xvc/LM6PhNX65x6FflhItAMGIeki+5RSkIuDk28Af9BgVBRuqR8MZQSBioWRGpc/nESa68RO5MX8ZnSWd/jRLLL/SWCVkYx6IrFKvO/5RV3xqe+yeszhYTOkOnMaUxjTpw+YzzJWGqzL6mP+Uss0/uml/7VcZqWmfM+FBRRKuIJgT+ca/kt4BG5xhCXClLzKVv+YNR7GagUSGSvwYFHbIMURXLfWlN7aRSPw== 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=OWxYkbe2Y4LElP2vRFCCGTc16oXe3zRM0yfKR/pPlz4=; b=l5vtfE3ScX3o6zCht7Yagn+WQSbUw8YB+odzG8pA98T6joSFOWVOmXxbzm+7oIOS9YcnBWjDnAC2toWfcC3jyyMwqOL1kigPaXM9p2L3JN+5Mf+XcT/KcHP2RhTpPSnDQAwyg+UAynFTm01FSD4ARNsdrRvPKSMyU0Hio7GYMSRHuEHJ3QHY55CtuPx+GUf0RxKPJ1xLZm3siHsIMB+fwNI2Dg8oiiWl5bsEDti29OSdJWjB3k0VeaDNTIJcqLdUkf9TVJnaGIaGo4Ukfc9fXLX3v6kGwq5U5JkGYGT5gYfRDXRW6isc+V2L4PdTbee+U19uYfTDOnvz3I3dIpT7gg== 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=OWxYkbe2Y4LElP2vRFCCGTc16oXe3zRM0yfKR/pPlz4=; b=T/eBtdoAyn3cogiTfuRsJTGX3ByG3WzAxv7eFKxUIa4Z00yKsxQDJsvx95qJwmIrPXM8GxHJ6CXDG2scjQQkQq4Slo6AHVvLEK1BWuE99O79MfJQVkfQ0/1rBKJRFl30xZY718wcm6HcZRWRzu+aFJJGlXmJEWge/He/QgqCtM5vOGBc5cerd+wvMH69UtJfehi5piB84HsWWHC+F5/puHQW1lOw8Nz0swH90s/5gKWBdoF2TmZXQpbtGwdp9K3h/nL99ZuzXcbxAcm81MtaG9PVb9IfkuwUyoA3docOWQway1DiAvTHemWtgl24L0lm9p9wLuat5XpjUgyGGA652w== Received: from CO1NAM11FT004.eop-nam11.prod.protection.outlook.com (2a01:111:e400:3861::4c) by CO1NAM11HT053.eop-nam11.prod.protection.outlook.com (2a01:111:e400:3861::396) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.25; Wed, 22 Apr 2020 00:18:28 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2a01:111:e400:3861::47) by CO1NAM11FT004.mail.protection.outlook.com (2a01:111:e400:3861::345) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2937.15 via Frontend Transport; Wed, 22 Apr 2020 00:18:28 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::e553:b74f:bf64:30c5]) by DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::e553:b74f:bf64:30c5%4]) with mapi id 15.20.2921.030; Wed, 22 Apr 2020 00:18:28 +0000 To: Matthew Brown , Internals Thread-Topic: [PHP-DEV] Any interest in a list type? Thread-Index: AQHWGA8iC1gTHdc7YEKHyxq4KzG+zqiEQHex Date: Wed, 22 Apr 2020 00:18:28 +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: x-incomingtopheadermarker: OriginalChecksum:089D8ABA4D4BC5E83F8C520115841CB31EF0702C04C59F2ADD31BECCCC969EF6;UpperCasedChecksum:41F8E14874C2AC3FA1006151685B9419BB99F2B5177D7083C25DF957A6AD3894;SizeAsReceived:7109;Count:45 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [WnlId+51/HcXw+6hf0GfhOLv4deFzFGTtM9wjRiWM6JYmdzQD/AN4ERna4AzJza/] x-ms-publictraffictype: Email x-incomingheadercount: 45 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: bfc9689b-67f1-479a-8738-08d7e652ae96 x-ms-traffictypediagnostic: CO1NAM11HT053: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Beu/vaGIsPihuFa56cMebKFaBdWuYBX+C0jBX4N3z8RP4sNOJ7bRCuN63nLDALYJXzLFlS8Map5qPaH7JeMon/eBOr2P7SyxWUwvrkUwT1Y8fToul9GOhoW5YjA9N65lj/P7Fqb66kMdPFa57bjD/ny/S80rR3tXFjTGc+7tvkqVPC+71CtNhSn4JOeFDUoTMR3arV4LXNQj507zRoDp1+imcYgSWoP8CUoy8a2nUHJLibtDFN7pHU52ckogg89g x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:0;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR07MB6618.namprd07.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:;DIR:OUT;SFP:1901; x-ms-exchange-antispam-messagedata: 2QLVJ+ZhUscAw+Ut/Dl8cUfIdGjQFv0a7YDW2IsGG+Yh7iuk0wdd4dgco6h9WfGMjL6AgJUdF4KAQ91cHpkSDq+rVaZCXbA33dlwBnfeHfF03eSCGYCth3BsAL396a6IIwIr9XVqV+fJXFQ/BFSMNXDjcPFyttACM03JmMilNlVyqRq4qijaFL8ofn2WdeXzZDNEhLzmTNiBLc45wzxyIA== 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-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: bfc9689b-67f1-479a-8738-08d7e652ae96 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Apr 2020 00:18:28.6102 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1NAM11HT053 Subject: Re: [PHP-DEV] Any interest in a list type? From: tysonandre775@hotmail.com (tyson andre) Miscellaneous thoughts on this:=0A= =0A= - Working to have a vote on https://github.com/php/php-src/pull/4886 might = be a good first step, and something I was personally interested in seeing i= n 8.0-dev.=0A= However, in the event you can't rule out that is_array($listParam) might = not return true in the final implementation you decide on, maybe wait. (you= said it'd be a subtype, and it seems like a lot of code would break, so th= at seems unlikely)=0A= - How would array_shift(), array_merge(array, list), array_intersect, etc.,= preg_match(), etc be handled? Would they return lists or arrays?=0A= - I'd really have liked to see data structures such as sets, variable-lengt= h vectors, etc. in core natively available as objects (or other types, but = objects seemed the most practical).=0A= Right now, there's php-ds https://www.php.net/manual/en/book.ds.php , but= if I wanted to use vec/list in an application/library that was used in a w= ide variety of places, I'd really rather have something in core. (the drawb= acks of using a polyfill would outweigh the performance benefits for a smal= l fraction of adopters)=0A= - If those data types were natively available, maybe opcache and/or the jit= could use specialized opcodes to reduce the overhead of offsetGet, etc., i= f the class was known.=0A= - References to list iyped properties `class X { public list $list; } $x->l= ist =3D &$localVar; unset($localVar[1]);` may cause problems in implementat= ion details if they're a subtype of arrays.=0A= Forbidding them in typed properties and limiting the type to params and = return types may work.=0A= - Having them limited to param type and return type checks (including some = internal global function return types) would be how I'd prefer it (instead = of adding a separate type elsewhere)=0A= PHP already has special handling for iterable/callable.=0A= - Future scope of a list type hint might be to add a deprecation notice for= `list ($x, $y) =3D $array` or `foreach ($x as list($y)) to avoid confusion= =0A= (even though it's currently unambiguous, and that probably will remain un= ambiguous)=0A= =0A= - Tyson=