Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115085 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 97581 invoked from network); 23 Jun 2021 23:31:55 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Jun 2021 23:31:55 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1848B1804F3 for ; Wed, 23 Jun 2021 16:50:32 -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,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10olkn2060.outbound.protection.outlook.com [40.92.40.60]) (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 ; Wed, 23 Jun 2021 16:50:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WfutA8Ou5oSYdwAy5cKiphtDP284v8zYuEW1Gqooy1FObyKAhODF1ZeAPB8PWsIA//xjWkNCnWhSyvFyp4PxpQjp2G/iyqWoJId6Q9hqwCfaPNwjYHr2oOBzN0Eb3gl0mcFCBrt0Ii2QpqH1Gkt8WQCTkp9bQFmD/TYxsnt/F2hW7RkIx51d7jeNQjYrqsNLlaDjaJOVgy79vvJfl0a8Q11GC6++BTO9JMAi7636Bq3Tv/OvwuBc5f0wXOHQUEaFmHaKlScqfcP7drcDnuZvnjnv0TbW3qWuypRhT3T5asroPrWSy7CJOUjEF+XKAODcONMxgcNLofQ8itt/J9vFzg== 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=obJ8iyK3H4XfXlrZl7IL6YDZa8UuQTvt29+gDLIFilw=; b=aum5MVOzgES6oVcSz44esz7p6xvWWPGK8ye2lBEQtzwlVZnJq3vCzpEbLLH9SxfwY4q99KrvEU4BidSv1lIkJmOhYHjJpID23F3bTa6B7u2VK2IMwCnCgb3Bk2UXcGEh/U155sYG6e5sYXweUp0TvHbPgPjph3BYV+wLwIS2jedobx3Q7G/YliGR+FGmPwOGtNvR2albETu/zVskHjD3sBoyV5ba3jnkfjagl7eLjMkMQPaSv+rCNVgKbAiX702kDBvXC8XYhv7v/99aANl/PFNUPz7CZwZcI7ZXUKYk1Zd+Fs7a+jdJQWsM3lj7PswlETLrD+FchMgMcno5KHPEQg== 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=obJ8iyK3H4XfXlrZl7IL6YDZa8UuQTvt29+gDLIFilw=; b=BCaky4X0hSFwVapPaykL6x1PoaLc61wROBBudTalY8jQEsegz7iWj8jLPfFUWwfrJH8zgcbTmw6IyA3lFzM1S4cZjj3TWPmC8xoztUM81U2ht3qsN8AiRw+CPSv9TX1uze6i3e6JnX6xGbmzCzoH7Tkda6a5BwxArwTb/zO9ghsX75ps7+htF0SnA6vD9Gp4zaP/ogI9MIipaaNlUl8d3XYH/hZroNUjPBZnkXdITYY8JzhoqaVDBr89iPRh+p70eP0UTrP7P50exyvgpj1cNpCur1QxMCeJ3zBx7vbcMkbXHna+8gHXrar6odKdxg6eH7zhY51qcoXjG2cw09suGw== Received: from DM6NAM10FT013.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e86::42) by DM6NAM10HT027.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e86::121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.18; Wed, 23 Jun 2021 23:50:30 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2a01:111:e400:7e86::47) by DM6NAM10FT013.mail.protection.outlook.com (2a01:111:e400:7e86::142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.18 via Frontend Transport; Wed, 23 Jun 2021 23:50:30 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::20ed:6cd1:4fe2:eea7]) by DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::20ed:6cd1:4fe2:eea7%3]) with mapi id 15.20.4242.023; Wed, 23 Jun 2021 23:50:30 +0000 To: "internals@lists.php.net" Thread-Topic: [PHP-DEV] [RFC] clamp Thread-Index: AQHXaF+YZ/LptmFjT0KKwGBdqqQTnqsiPoTj Date: Wed, 23 Jun 2021 23:50:29 +0000 Message-ID: References: <0BBAA2F7-02D7-4AEE-B48A-97436A0D8E5D@gmail.com> In-Reply-To: <0BBAA2F7-02D7-4AEE-B48A-97436A0D8E5D@gmail.com> Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:B70228A5A49339ACC5FEAE4F2CFA182B6BFAB040B8B1627FEB6BA6581020E769;UpperCasedChecksum:07232A25377250D19B7F2B5CF3DA98DAE42EADAB7D36E51DEE723D7D89457DF5;SizeAsReceived:6937;Count:44 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [mCo2YvdqyVqnuQGAr/8gLRdrqVFvK2HKW47P/KRm4ALsYSmixKe3duzXlp4yNTUn] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: f5ed2ab1-8263-49c3-13dd-08d936a1aed8 x-ms-traffictypediagnostic: DM6NAM10HT027: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 493DeDha7ojXySzLkf/hKo0s5RpRGADoAvMh6qBFf3rrykIxic1t+6MaH+dylTgl6fi0wizdFE61ZTZuyGT1s0Ze1YBP9BpvuAXTZcsYcggLEe4qzogiYhQYDeHyd5u6ydz8f7H2aOMXZJ7V5+nOSljOIGaDNoIvNhhvhFImLeu8faVwWahcDXlauzuqbcsh2O4fLvhrZvF/MEB+Jcgl0UF5bf6QmCEWQ2L9Ai0HeLSBSmcqje2AIAGibIV99HJ7PrYVM1XI2z3z80UTIhrWcHBlT/1UX5LOO9P4G4DopNFaolUo3Bd63x5+iC8HKrWLh3vN5U96XkJkrjfzutfVSbi0bOf63pI55TldaCyxDpyY3uofqV7iXtN6OL9bpsMqQSjPyTbgVgrBTc7JJLSKiqW9lAtX4Sf+MfiLMqjDNaiX3r/gkVKNOVVvOMVawNfKFUUoG3nN24z0cY27KOqF7A== x-ms-exchange-antispam-messagedata: ryhQwSBh5+6vv9npo+knKBReD4nWwxOekYSHVJEqAdfKj/bKRivXoIF/ivdUy/rwkQuuVvE+FpxXrxrDm1n4iGQzaUOa+OBjDfn4b/S/HTqpYL5xBqfcKAMiu+Q0U3nXINIKx4WdNS3t69DpJYRx06c0ugsu3ojzqPvNVx9ipitshcS/tPuKsc7MVbB1kJ307MneTuELjjsckL3rvkC0Bw== 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: DM6NAM10FT013.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: f5ed2ab1-8263-49c3-13dd-08d936a1aed8 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Jun 2021 23:50:29.9667 (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: DM6NAM10HT027 Subject: Re: [PHP-DEV] [RFC] clamp From: tysonandre775@hotmail.com (tyson andre) Hi Kim Hallberg,=0A= =0A= > The RFC for the clamp function is now open and under discussion, you now = have 2 weeks =0A= > to discuss, suggest improvements and open issues before voting is conside= red.=0A= > =0A= > Any and all feedback is welcomed.=0A= > =0A= > The RFC is available for viewing here: https://wiki.php.net/rfc/clamp=0A= > The implementation is available in a PR here: https://github.com/php/php-= src/pull/7191=0A= =0A= https://wiki.php.net/rfc/howto mentions:=0A= =0A= > Listen to the feedback, and try to answer/resolve all questions.=0A= > **Update your RFC to document all the issues and discussions.=0A= > Cover both the positive and negative arguments.** Put the RFC URL into al= l your replies.=0A= =0A= So I think the major objections are that:=0A= =0A= 1. This is easy to implement in userland and there's negligible performance= benefit=0A= (in code that is a performance sensitive loop, it may still be worse com= pared to `$num < $min ? $min : ($num > $max : $max : $num)` when validity o= f types and min/max are known, especially with the JIT)=0A= 2. People not being sure if they'd ever use it personally, especially with = the ability to customize parameter order and permitted argument types in us= erland=0A= 3. It's inconsistent with min() and max(), which support any comparable typ= e such as GMP(https://www.php.net/manual/en/class.gmp)=0A= (arbitrary precision numbers), DateTime, etc., and that may lead to surp= rises.=0A= Although PHP's comparison operator and https://www.php.net/manual/en/fun= ction.min.php have many, many inconsistencies, already=0A= =0A= (Though special casing GMP is probably a bad idea due to it being option= al and having an incompatible license with core for packagers)=0A= 4. I'm not sure what this is meant to do with the float NAN (Not A Number) = from the RFC description, but that's solvable=0A= =0A= ```=0A= php > var_dump(min(gmp_init('123'), gmp_init('456')));=0A= object(GMP)#1 (1) {=0A= ["num"]=3D>=0A= string(3) "123"=0A= }=0A= php > var_dump(max(new DateTime('@0'), new DateTime()));=0A= object(DateTime)#2 (3) {=0A= ["date"]=3D>=0A= string(26) "2021-06-23 23:44:47.302531"=0A= ["timezone_type"]=3D>=0A= int(3)=0A= ["timezone"]=3D>=0A= string(3) "UTC"=0A= }=0A= php > echo json_encode(max([0,2],[0,1]));=0A= [0,2]=0A= ```=0A= =0A= The RFC should probably link to this RFC announcement thread https://extern= als.io/message/115076 as well.=0A= =0A= Thanks,=0A= Tyson=