Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119299 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 83469 invoked from network); 17 Jan 2023 19:46:27 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Jan 2023 19:46:27 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BA0D1180511 for ; Tue, 17 Jan 2023 11:46:26 -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.6 required=5.0 tests=BAYES_00,BODY_8BITS, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 17 Jan 2023 11:46:26 -0800 (PST) Received: by mail-wr1-f44.google.com with SMTP id d2so11620390wrp.8 for ; Tue, 17 Jan 2023 11:46:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=pIJO9/AjlbVpzxf+h53tGX45QgEWfHkrwKG7kBCqkWA=; b=mJkHk5pDsqxp89mciHujmlujpMpTTEFXKphFASN+mzmCvLJgH/jaXskL2jF8sST6Hx QfDjHAPesvpgixKcIucKB7ER7JThxVyDzFhpQ0D+t3K5LNlwtvtrGeA5C0P5Tsh26EEL cuiCf2rJ3cQ8wJfSSOM1f5Dt+gZkiTn4cmQghQQRyXWXe2GRZSK2c3hL1cxBfu/cHUkF iydYXtx6nUERtn3V7NlKFHCs+j9DVeDVB5b4zb69rYuhIMpphoLrCOIzKk6Yyan8D2n5 ookWsYU3vBYwhiXazRDkhJYbORyAyXHlF9F2qbbBIxHMZfrxriCtPPm/XZ4/i4ooZclM 4H3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pIJO9/AjlbVpzxf+h53tGX45QgEWfHkrwKG7kBCqkWA=; b=YdfyAiaaCe/5vlKgArUKz44/z+nudgaw5X0ZrhEsb4/ZoeXnB8SNlM9OeIRGYBw8wc kF8eiyg/YO31NDrfGeQXgzIuwyy1QQc3NFAvnU1YAR/3CxRptFi+Y3hGQEjp27AXl4kd RT5iYzedOFIqzxfqnpB3R+BeHboE3TjS7TG4OU8wrSMenSagw9WLSWn9qceIufSUjBT7 NBINWqtKMFZR/X3l3qr65TbWF0ggPpw4vqU9jq4SdTplP3DHCJ6OWvV6NyMUuruZcspF 7AOh0XtK++mxJ9KZKSfDz9H07wJxnejA5aqsmFfeikuc125WzRmgij0WP+PjfKeNcPFE b5eA== X-Gm-Message-State: AFqh2krkVCxw9DWYRHgOrQZHFjODoh27VX/JtCyxkhTgBBI1nyMadMIS h3TD9uj3klYxl/0sl+8bma0J4BkAffE= X-Google-Smtp-Source: AMrXdXt+Y9T2RQI8CdeyM2BQCnrVWSll+oPBTp+RzLEcT+YXVg1zFY2ged9kvhI5Abr5JIUoLW5hDQ== X-Received: by 2002:a05:6000:1f95:b0:2bc:371a:8a2 with SMTP id bw21-20020a0560001f9500b002bc371a08a2mr3854467wrb.37.1673984785258; Tue, 17 Jan 2023 11:46:25 -0800 (PST) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id bg42-20020a05600c3caa00b003b4cba4ef71sm49345964wmb.41.2023.01.17.11.46.24 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Jan 2023 11:46:24 -0800 (PST) Message-ID: <4a676ff4-bbd6-31b1-7055-8cd7f6894a54@gmail.com> Date: Tue, 17 Jan 2023 19:46:20 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 To: internals@lists.php.net References: Content-Language: en-GB In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] [RFC] Path to Saner Increment/Decrement operators From: rowan.collins@gmail.com (Rowan Tommins) On 17/01/2023 14:28, G. P. B. wrote: > I would like to start the discussion on the Path to Saner > Increment/Decrement operators RFC: > https://wiki.php.net/rfc/saner-inc-dec-operators > > The goal of this RFC is to reduce language complexity by making $v++ behave > like $v += 1 and $v-- behave like $v -= 1; Hi George, Thanks for tackling this. I heartily agree with the aims of this RFC; the current situation is a weird mess of special cases, most of which are justified only by "it's always been that way". > I am expecting the contentious part of the proposal to be the deprecation > of the PERL string increment feature to achieve the aforementioned goal. As Craig and Mark point out, this functionality does have legitimate uses, and I am generally of the opinion that deprecations should either be of broken functionality (as is often the case when upgrading Warnings to Errors) or come with specific instructions for a replacement. Perhaps therefore we should introduce a new function, string_inc, as the official migration path for deliberate use of this feature. This could give the same result as the current increment operator for supported cases, but throw an Error for cases that would currently be left unchanged. A polyfill using the existing operator on old versions would look something like this: function string_inc(string $input): string {     $output = $input;     @ ++$output;     if ( $input === $output ) {         throw new Error("Unsupported input to string_inc: '$input'");     }     return $output; } Without the need to interact with other types or existing behaviour, I think an accompanying string_dec would also be less controversial than previous RFCs. Ambiguous cases like string_dec("a"), string_dec(""), and string_dec("0") could simply throw an Error. Regards, -- Rowan Tommins [IMSoP]