Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108343 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 77348 invoked from network); 2 Feb 2020 00:48:53 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 2 Feb 2020 00:48:53 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 303911804D1 for ; Sat, 1 Feb 2020 15:00:24 -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=-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 NAM04-SN1-obe.outbound.protection.outlook.com (mail-oln040092011053.outbound.protection.outlook.com [40.92.11.53]) (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 ; Sat, 1 Feb 2020 15:00:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b+UlrOByTZkJKQehCABkSGgR1f4nbTFg33ZlCFbmQ1OJwqz2+ma9eJ2XKSYJ05bibkH4QuNgMiUyTuSApApx0h1ORzltzdUpojK9qhi15VKvjmp87qGPFKkpNgS+RjNLvO23bSDMR2Lv/rW3eSHrWGoE1xFKqzVtYE/FYaQCFUpcEyiij9ybNzbWfD/P4JTHTJE3Pp+gZcNitKe7xBR3xZe3gsJYnba2U1VcA6XcmYlUCkMrcsh87VEbRUPG1888JyGMZTr6foPu8FQ3xjJXOova+BKF0u+IjE1Pd6ZjDpzCeCNq+XCBz6DoZAqQo1ffb1/YiYsHML9pVMDFLBi0pg== 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=NVNdLgAFkYKxWM8kRZ7G8+qRkOT56LSbOKarwjj13XU=; b=e1bTvyAS3RxgG7aqvvYcCNscll+QZ94x3WwsRfS5kA+mz84LWYJPA2tCWHuj1X+L5BLh1yFgP+k1yvkTIJxO/YRqXEeSUb1mrbMnnwqI0Ik2OKuwEaBJRidBHIQ/QPrfW2qBT9mlEpFzsDunSZh9vECR0vQTW8RKOCEWJjn3+JVg5YGNzsrXm4jqOkvyx4Nj9DSYjh12rWQXZercgtfyQqWcgJPWi2eVUAV3MKmpLld/3ifFzKuTfSAC4g94RO5tg2FHejyYrmdKu0D8/ALrPz6zlE2cAWud/q+/QwxR4NgiYj/ThZO3pCC9DUCNqSP5L4MneSS0wG+FrvhNhU7ezw== 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=NVNdLgAFkYKxWM8kRZ7G8+qRkOT56LSbOKarwjj13XU=; b=roJPHgkzGM7WxRvQvOVzSoW0W08Ee01hSZqCdbGKacpGVBaigphqtH4al+PDfViIcwy/WKUJ2m2okKF1aqtmq9Jv3COWtXVXb78SRPyIgfz3FkJrZefkoVe37qbB5hS3VqoiaId3zqI9zQ07gU34BrkbL/jk27u9SWb+s6w3pzlmTEHZNXP18zH79EeMgYcTi0kwPAXiBqYnhdbRw9/8SyXNOepthwiKWwDISIKEgs0Cwm5o1UsXi3VZvtzSXhK/chLWrFCT9Ss25RTU7xOfDI+WYHNM6irKtycknN9aPksyXke7P08XWO/GxIH1duhUaBon8fRxin4LNaPQkTrFng== Received: from SN1NAM04FT018.eop-NAM04.prod.protection.outlook.com (10.152.88.60) by SN1NAM04HT242.eop-NAM04.prod.protection.outlook.com (10.152.89.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2686.25; Sat, 1 Feb 2020 23:00:22 +0000 Received: from DM5PR07MB3067.namprd07.prod.outlook.com (10.152.88.59) by SN1NAM04FT018.mail.protection.outlook.com (10.152.88.159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2686.25 via Frontend Transport; Sat, 1 Feb 2020 23:00:22 +0000 Received: from DM5PR07MB3067.namprd07.prod.outlook.com ([fe80::1133:bcac:caf1:d588]) by DM5PR07MB3067.namprd07.prod.outlook.com ([fe80::1133:bcac:caf1:d588%3]) with mapi id 15.20.2686.031; Sat, 1 Feb 2020 23:00:22 +0000 To: "internals@lists.php.net" Thread-Topic: Planning an RFC to allow calls to global functions in constant expressions Thread-Index: AQHV2VGmZkZM3HvoRkWNVub65jMyhA== Date: Sat, 1 Feb 2020 23:00:21 +0000 Message-ID: Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:48318EB37CAFE4057BFF22AA770C130A277888EFE5D192E0CEE4E474BACEC170;UpperCasedChecksum:02999E07571FB37F2EB67CFFDC3F9B0149B0589D486166F9CBB040F0B008BD31;SizeAsReceived:6791;Count:42 x-tmn: [X5UCI2+fQLprLgcIYAmzNZpxpq2Tcv1Y] x-ms-publictraffictype: Email x-incomingheadercount: 42 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: 6a74d8bf-93fc-4823-9082-08d7a76a841f x-ms-traffictypediagnostic: SN1NAM04HT242: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: T5qEOAE9r+tKCNfC+Fzm63yoZHjJLdW3kDoa2jc0sDbI9Zxg1Pr+FaAFZ2LOsXi4O0O9yhbX0uKMlfWz80lTZM0qrTmL6Sg0Wi9g+BAR6vDNzWBInvThE2PH0i8iC8AShHMxTVYpMrhwHRX6m/4CrvmPwzGSzmiNQ0lb4c0tEbMhWJxjkWHKXOyjrx7rvnCr76wwEcqTlcVAiwPpmGJaDDfvPmDRokRH9t0mQ5eQkh4= x-ms-exchange-antispam-messagedata: UXl7DrbpVGdAl3c7YE7AadTrVUCfcFTd+op6I+YFL0GZRNLxqzCHDceMyMIdHoj4KnYHiu518nQIRPhSmD0rz3goFYI3mKeS8+QlqWBYi2oFG+wGka0OtjHbiosqQg7qlEPffkZsWWzDNa/u+rMO8Q== 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: 6a74d8bf-93fc-4823-9082-08d7a76a841f X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Feb 2020 23:00:21.9778 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1NAM04HT242 Subject: Planning an RFC to allow calls to global functions in constant expressions From: tysonandre775@hotmail.com (tyson andre) Hi internals,=0A= =0A= I have a working implementation for calling global functions in constant ex= pressions at https://github.com/php/php-src/pull/5139 =0A= (see PR description for more details, see tests for how edge cases get reso= lved)=0A= =0A= If there was interest, and no implementation or process blockers I was unaw= are of, I was planning to set up an RFC with votes along these lines:=0A= =0A= 1. (Primary) Yes/no for supporting calls to global functions, with or witho= ut the below limitation (requires 2/3 majority)=0A= 2. (Secondary vote requiring 2/3 majority to allow calls to all global func= tions) Support calls to any user-defined or internal global functions, not = just unambiguously resolved calls to the deterministic, side effect free on= es that are guaranteed to be installed in core extensions.=0A= =0A= Alternately, have a first vote on allowing a small subset of global functio= ns calls, then if that passes, start a second vote on allowing all global f= unctions.=0A= =0A= For example, allow `\count()`, `\strlen()`, `\array_merge()`, and `\in_arra= y()`,=0A= but don't allow functions such as=0A= `\strtolower()` (different in Turkish locale),=0A= \sprintf() (Depends on locale and `ini_get('precision')`, but so does `(st= ring)EXPR`),=0A= `json_encode()` (The `json` extension can be disabled),=0A= or calls which aren't unambiguously resolved with `\` or `use function`.=0A= I'll assemble the list when writing the RFC.=0A= https://github.com/phan/phan/blob/2.4.8/src/Phan/Plugin/Internal/UseReturnV= aluePlugin.php#L190=0A= has a list of candidate functions (non-deterministic ones such as rand() wi= ll be excluded).=0A= =0A= I mentioned this earlier in https://externals.io/message/108238#108238=0A= The use case I have in mind is different from what was mentioned there,=0A= and this is *just* adding supports for function calls by name, not any othe= r expressions (variables, properties, methods, etc)=0A= =0A= Motivation for the voting structure: There are many opinions on what a cons= tant *should* be used for, e.g. one opinion is https://externals.io/message= /108238#107992=0A= =0A= =0A= > Off the top of my head, I can think of three types of things that you mig= ht call "constants":=0A= > =0A= > 1. A value that will never change, and you just want to give a name to. F= or instance, MINUTES_IN_HOUR=3D60=0A= > 2. A value set at compile-time, to hard-code a particular condition. For = instance, DEBUG=3Dfalse=0A= > 3. A value which is set at run-time, but happens not to change during the= course of the application, so should not be over-written.=0A= >=0A= > PHP's constants are designed primarily to be type 1 - they are literal=0A= > values, hard-coded in the source. Unlike C, there is no standard=0A= > pre-processor for PHP, so type 2 is rarer, but it's possible to=0A= > implement by manipulating the source file before deployment, or even=0A= > when running the autoloader.=0A= =0A= Thanks,=0A= - Tyson=