Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112461 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 74890 invoked from network); 7 Dec 2020 18:20:04 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Dec 2020 18:20:04 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DF49B1804D1 for ; Mon, 7 Dec 2020 09:49:01 -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-DM6-obe.outbound.protection.outlook.com (mail-dm6nam08olkn2040.outbound.protection.outlook.com [40.92.45.40]) (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 ; Mon, 7 Dec 2020 09:49:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EkALQbCS/rd3pL2F3QVgqjK6vO+Ib7f5eDSpbpdmW0eI59+3G3zpV2gobfyElZqdVGoPPXp/YbvivVqZIHe28NC71CmTpr64Ad4EYwW+9cDH1MUDoKruUhJ3Sp0H8RFu49No5CiqULfVJmDJqQtD5DKbe5UJcRfmYJBp1p+Rpk18w1lfHzVvv32+VIcnjp0lME+i39gEG9oimtfv9C3a1oUvKvq+dju8j+UbgtGT1OuXDkmKB/D6j+WJtmF1bxN6MX4/uuoQubYWc68y4K0uoi9pLvHpI0CnCNix+RXype29TUGsDV4wfH03pPDH+mbOmKmghwt4ScEIhKQ4Y0bUMQ== 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=/l5Evv6XDWg8k1uwMVdewlTs/9h4SrSCn5RDhVouvWg=; b=H36iXMv8CKKEL1qCn8+YnxQIKBc2+RDSuZ7vpbiX+eJiyih0UxoRcBxjSQ4NgHPf1WnS283Sh6ox1+2pJThnAUaj6KTtDBFMtOKcpqt+Pwa63Xo0T/Jlvl2v6z7SXbDTInGyb+u92NQzkr9JbBXrK+ZWSLSFFg5ThhJsUhHYoEur/f03vEMjuJYgvfeJpQ3fNmLv/Y+1dyi6boKXNhYRVd1FdDY0CSQiwwbIryOb9vVF2wmq2GqRvbk+avsH7W0sqVW1JlddruHnG788e2v7gZjrfQYgr5e/RTuYpjj+QuLNBt/1Gvjqw5RafjI87gcuL20a9/9Q0NyAPTv0/tz8sw== 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=/l5Evv6XDWg8k1uwMVdewlTs/9h4SrSCn5RDhVouvWg=; b=W5BBNey+P0qahlA3hRL+i4sU3t62EuB7r2oP4w64nSyJMkHDQ2HrnuuKvkrV3hAUmxFJdTZqBQqy0b9xxAK61ldlIj7OEAFQJuQFZot9mswadXr/DyTpvhoGkHDeslOEVaYC+f0Z+SIekow31hAfRvmfTEEL/hRkN06Z0rNFcklyKc0k5ag3WsP60cpCrMQJejCrQcJE6bC2OMJOB5tc4J4hdHgJQRPnroet7NeJzK7Wp4gksMoC+E2STHSCfkM6ugBno6XhgbL7OLLrz7iCIkgISZ5UATEqopEH+A3F0umhfV/rAVz/nSGizS6zZ8DU4LaJsj3/Psi4soFv/+gb0g== Received: from CO1NAM04FT059.eop-NAM04.prod.protection.outlook.com (10.152.90.52) by CO1NAM04HT231.eop-NAM04.prod.protection.outlook.com (10.152.91.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21; Mon, 7 Dec 2020 17:48:59 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2a01:111:e400:7e4d::51) by CO1NAM04FT059.mail.protection.outlook.com (2a01:111:e400:7e4d::449) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21 via Frontend Transport; Mon, 7 Dec 2020 17:48:59 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::d99c:15a8:f595:d00]) by DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::d99c:15a8:f595:d00%7]) with mapi id 15.20.3632.023; Mon, 7 Dec 2020 17:48:59 +0000 To: Nikita Popov , Larry Garfield CC: php internals Thread-Topic: [PHP-DEV] [RFC] Enumerations Thread-Index: AQHWypS0dp+yj+uVBEGwghKNxSJW26nrcReAgAB3+fI= Date: Mon, 7 Dec 2020 17:48:59 +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:54ED2912A25FC4F70DD74EE32D6A5B3F12865914DE4A7DE9CA3225359231DE1A;UpperCasedChecksum:8F6732CBDBEBDA5EE4EF37C980A8DAFD902233C5C6954714CD6AAE3E0F903470;SizeAsReceived:6981;Count:45 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [kOeUhU5S5zGLF9y0ZqpkbEzC1sFHGidr] x-ms-publictraffictype: Email x-incomingheadercount: 45 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: eff7e483-b7fe-413f-180e-08d89ad860a6 x-ms-traffictypediagnostic: CO1NAM04HT231: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: H8QthYtiuJgZaingKc68DWzCD+mBJHyh3D9QM0JfUJqjlV17Tc5nJfid4vV7Jk5JGG2Ftv2wPeQ5eB5hAIzFHkBvd8fkVQd2PzpP+RZ7x6M4c5jzVwzW2uRVvXEcWPr7rsOx0UT9OzOkruPgmGJcfBBwBwdXrcNr89/nde06Rk0QcWKaRiWHpSDirkEfCOr8u8XpOD2GhnLkV/48Kea6tA== x-ms-exchange-antispam-messagedata: 35Mh93KoaSZNRDw5KAwuM+e2062kprs4ncoqO4zOmtN3oP4vtFiGBFvhg6xiowJheUau9CDJYyHpDU7HHe0WnSYE2Bo+giCiIcsAbG8QZCTKNDTJcX91+siTgpfHHqbdpIWgGrsGAL94J8yEFSgQAA== 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: CO1NAM04FT059.eop-NAM04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: eff7e483-b7fe-413f-180e-08d89ad860a6 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Dec 2020 17:48:59.7196 (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: CO1NAM04HT231 Subject: Re: [PHP-DEV] [RFC] Enumerations From: tysonandre775@hotmail.com (tyson andre) Hi Nikita,=0A= =0A= > > At present, no.=A0 They're "just" objects, and you can't assign an obje= ct=0A= > > to a constant.=A0 Unfortunately I'm not sure how to enable that without= =0A= > > making them not-objects, which introduces all sorts of other complexity= .=0A= >=0A= > This should at the least be clarified in the RFC. Is this a limitation fo= r=0A= > constants specifically, or anything using constexpr initializers? For=0A= > example, is writing "function foo(MyEnum $e =3D MyEnum::SomeDefaultCase)"= =0A= > possibly? It would be a significant limitation if it weren't.=0A= > =0A= > Generally, I think the limitation on objects in constants is mostly=0A= > artificial and you should consider lifting it as part of this RFC.=0A= > Previously you simply couldn't create an object in a constexpr initialize= r,=0A= > so supporting this wasn't really relevant. With enums, this becomes=0A= > important.=0A= =0A= I agree it should be clarified (and have phpt tests).=0A= =0A= Another option would be to lift the limitation on objects in constant expre= ssion,=0A= but only on immutable objects.=0A= (currently just enum values)=0A= =0A= There's a range of opinions on internals over what a constant would ideally= be.=0A= (something that is actually constant and not dependent on environment to ma= ke code as readable as possible,=0A= or something that does not change at runtime, etc.)=0A= So there may be objections if the change introduces the ability to write co= de like this,=0A= but maybe more developers would find supporting only enums acceptable (cont= inue throwing for non-enums):=0A= =0A= =0A= ```=0A= define(CONFIGURATION, new stdClass());=0A= class X { const CONFIGURATION =3D CONFIGURATION; }=0A= X::CONFIGURATION->endpoints =3D [$dynamicUrl];=0A= // do stuff=0A= X::CONFIGURATION->endpoints =3D [$otherDynamicUrl];=0A= ```=0A= =0A= Then again, this suggestion to only support enums may also be an unsatisfyi= ng compromise.=0A= =0A= Regards,=0A= - Tyson=