Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111375 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 22685 invoked from network); 8 Aug 2020 15:20:50 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 8 Aug 2020 15:20:50 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 21E6C1804C8 for ; Sat, 8 Aug 2020 07:19:31 -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-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10olkn2077.outbound.protection.outlook.com [40.92.41.77]) (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, 8 Aug 2020 07:19:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QX3wG4uG7LetmBMcKiS0i3OOySwwwnle2TxKVy/6FYFNzh6FWZzl/hb3uf2bzCRKtjUzi6iQAA2b1UnYoKbiBreN4ISMRvQ1jhvPWO4FvlTx1CELNHrN7QMHEWWkaFOdaFOjCRfKGomBQQHwrBKVDELYHzkLeK6SN51OGw8o/LJl1UGMr+dl/kmpGh4B21xh5Z6PmohF/l3ggbdinKCgvHz1pXPCDi7Apqeiz9PcKjabA5oBsWiVYfz/K52jD7owqIEZipAwVzuO8EhmJcvLh+SR7IjLUcoWPFymxZn7FDjuljw/GeEfN54iZikfdEeErnNKPdpFCitfNzZiC6SAlg== 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=wsxXA0M0T3a2z0QtO9ch0+xiqVCMRTmCmzHubUlqkM4=; b=mkHUETxpEruLnYN2DDCpIJXwTfM1hLpPPGwCWbpKc5x0johMC281qYolf3YJPG5iouYKXLNvihTYqW4ByWUYOSH0D6ag9ALpmGSR7u7YuBzV9l5eejN8e/3fE5M+NRsSI2M43P4pq3Xi2AgdxkpEm4staB/WGi+weyBMXeyzHBKsp/HUZ+9SFFW2zrOYk4VwjZGoF/9VX3SSKeb3UENwyjtAplUo8IteeQNBUzgwtfdE3bQhcJpmOmph/o4NFL6TiZ2EzkpuyqZqdZv31yKPzoEELGpjVWIlQQ7+mJLH2m247YmSzmsA1q9usmJvbAHTAQ+2rqB7lctVI7m5qPHSAA== 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=wsxXA0M0T3a2z0QtO9ch0+xiqVCMRTmCmzHubUlqkM4=; b=I8mKHzCpH1veMoC/ha3btVIhQuBQJTYKc2bWsIzVqYIqT51/Yb8iF2pa6eLHjKh+6bMRVCsP3bYE8bbhVkSPmBZ+STI3uy8RTO2K/UMLljJ3ftpl+Y0ug2sme1OZb7ql5DONdPASuau347Mn7zbiYdpwdjs+D1atfBBpR9xjTDjjRxEqXhIbtbZ97bUf21k4wq3y9KO/5vNMDqf/kPw0S+Jw695xW9SpRzTreCEo4UdirlI8qOQZa92mz1rEntRER05M1xrzDzh3wO3xTzeDi/q4r9nSZTITezQWpGKi6wTkvgVE7TURa6V7Dv0nyc51Cw1EuJlGDKIv8yZJJ6mhUA== Received: from DM6NAM10FT065.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e86::50) by DM6NAM10HT211.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e86::434) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.16; Sat, 8 Aug 2020 14:19:29 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2a01:111:e400:7e86::45) by DM6NAM10FT065.mail.protection.outlook.com (2a01:111:e400:7e86::181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.16 via Frontend Transport; Sat, 8 Aug 2020 14:19:29 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::cc10:a3e2:1dcf:adc1]) by DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::cc10:a3e2:1dcf:adc1%6]) with mapi id 15.20.3261.020; Sat, 8 Aug 2020 14:19:29 +0000 To: Andrea Faulds , "internals@lists.php.net" Thread-Topic: [PHP-DEV] Re: Proposal: shorthand syntax for initializing arbitrary-precision("bigint") numbers? Thread-Index: AQHWbYG0jbTFMj2RlkKxINS6VcUHrKkuO34J Date: Sat, 8 Aug 2020 14:19: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:09558F4AF71F41D9BC5644C6F7D941A3C6EAE7701FD02E9F77DB4376386F896B;UpperCasedChecksum:0E36D51710D82486EA4E0F25B7B4FFDF63B8E1A046AC181EFA47497E39BB38DF;SizeAsReceived:7303;Count:44 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [CujKI9frmEuYRaG2F4OeYg3bkxIPYAR083hmcCAx4d7Uh+7kNgDejIY2LpEwKr7N] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: 6b3d0b59-5781-47be-6faf-08d83ba60fe8 x-ms-traffictypediagnostic: DM6NAM10HT211: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: hD+Ld6pi5snaz9qOgouXBqVqCrkmgJSBz6xbYDQn1llds2YxNqRMNlX7Ne7sX0dN4ulhqovwJod1D6P452IFJRrW9/61lysv741NBQU2GeBtkDtX5Y46lWRBiIWLR1OhvhIT775nVeg+K//MDEkVWsmkKz2UffkwugQPP7KJ3z4xRPnAJbkasMve15T/9vj9d7Kn4n337A4YPVRycpVWhvXsKfcrT0HOMQHBpHPcEiK+eBpttQO1afck0KoQtgk2 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: 5JLYP75nnqTZAnxuL0Me/wdurSGhjlcRoC447W5z2nR5/h1N0ysf3slghpsXUcAlcZtCn3/h2vLLWGLyxnwoAslb7YhiUWpZNTpA3Ua5P6jVsatvbppvzHH+4Syn7yJTqE/Md5BtcfXPFLwbRhek5dBMP+xNy1iqKTJUiJ/M+auGaYUCDiFgqm8GgR3cuw7lxZZqlMsMNLH3bsD8gHiYIQ== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-AuthSource: DM6NAM10FT065.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 6b3d0b59-5781-47be-6faf-08d83ba60fe8 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Aug 2020 14:19:28.9406 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6NAM10HT211 Subject: Re: [PHP-DEV] Re: Proposal: shorthand syntax for initializing arbitrary-precision("bigint") numbers? From: tysonandre775@hotmail.com (tyson andre) Hi Andrea,=0A= =0A= > > What are your thoughts on making `123_456_000_000_000_000_000_000n` a s= horthand for `gmp_init('123456000000000000000000')` (or a call with equival= ent results)=0A= > > (similar to existing backtick string syntax is a shorthand for `shell_e= xec()`)=0A= > =0A= > We could do that, but maybe this is a good opportunity to do something = =0A= > with a wider benefit than GMP by having a generalised solution? GMP is = =0A= > already special in some ways and it would be a shame to have even more = =0A= > functionality that privileges it.=0A= > =0A= > For example, what if we allowed string prefixes to have special =0A= > user-defined meanings, like:=0A= >=0A= > n"123_456" // expands to: gmp_init('123_456')=0A= > u"foo bar" // expands to: new UnicodeString("foo bar") (some class I = =0A= made up)=0A= >=A0=A0 d"123.456" // expands to: new Decimal("123.456") (also an imaginary= =0A= class)=0A= > =0A= > This would be a similar idea to JavaScript's template string tags: =0A= > https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Templat= e_literals=0A= > =0A= > How you'd define the mappings from prefixes to executed code, I'm not =0A= > sure, but we could just make it call a function by that name in the =0A= > current namespace=85 though that would prompt the question =93why not jus= t =0A= > write `d("123.456")`, which is already possible?=94 and I don't have a = =0A= > good answer to that :)=0A= =0A= I'd feel like the former syntax would be more readable/familiar.=0A= =0A= https://en.cppreference.com/w/cpp/language/user_literal also exists. It sup= ports literals like `2.0_km` or `"one"_w.=0A= `void operator "" _km(long double); // OK, will be called for 1.0_km`=0A= A brand new type of operator function separate from global functions (possi= bly with autoloading) would be one possible way to execute that.=0A= =0A= That being said, I don't know extending that syntax to user-defined functio= ns would pass as an RFC, and I don't personally interest in adding it.=0A= =0A= - In C++, you'd know if there was a bug at compile time.=0A= The C++ compiler would tell you that the program could not contain `1.0_k= m + 1.0_Litres` or `1.0_km + 2` before the program could run.=0A= - Maybe this could be initially limited to C extensions (PECLs) during init= ialization?=0A= The ability to perform operations on user-defined classes is limited beca= use https://wiki.php.net/rfc/userspace_operator_overloading didn't pass. = =0A= - User-defined operators would also enable code like `$x =3D download_url"h= ttps://....";`, which may cause confusion reviewing code but should hopeful= ly be rare in practice.=0A= - If somebody ended up adding user-defined literal syntaxes, I'd really hop= e that those would be separate from global function symbols and unambiguous= ly resolved (e.g. by not having namespaces, or by requiring that the operat= or be explicitly imported to be used)=0A= - Different frameworks may end up with conflicting definitions of the same = operator for short operators.=0A= - Also, there'd be no indication if there were typos such as `$a =3D yeeld"= END";` and I'm not sure how lexing would work with prefixes. Suffixes may w= ork, I'm not sure.=0A= =0A= Thanks,=0A= - Tyson=