Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108802 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 68866 invoked from network); 2 Mar 2020 15:41:45 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 2 Mar 2020 15:41:45 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0E4D41801FD for ; Mon, 2 Mar 2020 06:00:39 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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-io1-f52.google.com (mail-io1-f52.google.com [209.85.166.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 2 Mar 2020 06:00:38 -0800 (PST) Received: by mail-io1-f52.google.com with SMTP id h8so11619619iob.2 for ; Mon, 02 Mar 2020 06:00:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mwInewzZHwh/ShGIk8+OTSGii9iO3tjT//AYrpvSH8I=; b=E/8XcnqLXTOlORwB1JmilvdZCdQtQq6zi7n/Z+Fwn82pD4HnAz236aqHzGsRVo6/hY q+A7LkI3T11fXc0Vl4C4kiKSD3ebhQGI19001vrk5cCUfA0BWvSIPQ+R5YQ9ItyAlGRB CW4D7W/O2/qtAVvBv72zGlhTjp02+nJaRV28l9U1KqqY1awBGsZNwPflwEUIxa8O0mdY q8Y/dRoP14d4zll2RdGLbLm94XkJ8z/cdeYejjSgY0NqL4FchXz371V2kMdQGrFUddfP q0AOqQFf1oqt07LxXfRHdxYFbIL5NaYnamlUk8F482emm6ccVbawrFmuaANo8S+6NSIM Amow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mwInewzZHwh/ShGIk8+OTSGii9iO3tjT//AYrpvSH8I=; b=QlMDZNa90G80Iz4QhJzTkudTm3QTKOP+YR8YrFAUh5a7cRe/6fAS3Yjomlk6xLr5Ly /jOAoMv11BdJ92frpR7lj3HlB38DWu4o4yQc7k+zSDnPXaLmfGqS0zioCf1mi4hE80IJ /v4jARYNMKoRYFar/n40UpDVIYsdS8ZX0mtAZ6IFG9UVdNgyDNS87Q+ZYR2mPFhFooMx A3foqygRgNcoNYBPvLJVYbYQHjX1s3X6HjrBXNwPSRv2P7eO1LfuEGEX3HTKKybQorC9 +xes6zInKKciO+ev8YexG8QIlFPnnion6nVPzzyRtuS3DLi+spIH7LcyV8CRAZKhvePh wvAQ== X-Gm-Message-State: APjAAAW9MkAjDQxYvD/IjnYJGjTNg5X+V88KoVb3WmeP87tZ5uBzT+Dk rWCaXur8DVcOgFu1gH/FCzFW3LA2FafGHjgfCnU= X-Google-Smtp-Source: APXvYqynGAJZP9j0rS6vVvSNjdSwEK0YCK9C6cVbMPT1Wt7sa3mrPo988a5US3A5ERqeJlBCxTpydfAlicj8bZIDH4o= X-Received: by 2002:a5d:94ce:: with SMTP id y14mr13149166ior.165.1583157633817; Mon, 02 Mar 2020 06:00:33 -0800 (PST) MIME-Version: 1.0 References: <3f615d82-a84b-697b-5c02-8d915270f92c@gmail.com> In-Reply-To: <3f615d82-a84b-697b-5c02-8d915270f92c@gmail.com> Date: Mon, 2 Mar 2020 15:00:21 +0100 Message-ID: To: Rowan Tommins Cc: PHP Internals Content-Type: multipart/alternative; boundary="000000000000631fbe059fdf9cde" Subject: Re: [PHP-DEV] [RFC] Increment/Decrement Fixes From: ocramius@gmail.com (Marco Pivetta) --000000000000631fbe059fdf9cde Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hey Rowan, Overall against the RFC: `++` and `--` (prefix and suffix) are supposed to be used with numeric values, not with other types, as that makes everything only more confusing. Code written (intentionally) to use `++` and `--` against non-numeric values should **NOT** pass a code review, and I am sorry for those that have to maintain it if that happens. Changing the current behavior, regardless in which way, is a BC break: might as well make the BC break useful: RFC Proposal: `$a =3D null; $a--; $a =3D=3D=3D -1`. Let's make this an expl= icit TypeError instead. RFC Proposal: `$a =3D null; --$a; $a =3D=3D=3D -1`. Let's make this an expl= icit TypeError instead. RFC Proposal: `$a =3D true; $a++; $a =3D=3D=3D 2`. Let's make this an expli= cit TypeError instead. RFC Proposal: `$a =3D true; ++$a; $a =3D=3D=3D 2`. Let's make this an expli= cit TypeError instead. RFC Proposal: `$a =3D true; $a--; $a =3D=3D=3D 0`. Let's make this an expli= cit TypeError instead. RFC Proposal: `$a =3D true; --$a; $a =3D=3D=3D 0`. Let's make this an expli= cit TypeError instead. RFC Proposal: `$a =3D false; $a++; $a =3D=3D=3D 1`. Let's make this an expl= icit TypeError instead. RFC Proposal: `$a =3D false; ++$a; $a =3D=3D=3D 1`. Let's make this an expl= icit TypeError instead. RFC Proposal: `$a =3D false; $a--; $a =3D=3D=3D -1`. Let's make this an exp= licit TypeError instead. RFC Proposal: `$a =3D false; --$a; $a =3D=3D=3D -1`. Let's make this an exp= licit TypeError instead. In **addition** to that, we may propose removal of `++`, `--` and similar from non-numeric types (will lead to TypeError) like Andrea started in https://wiki.php.net/rfc/invalid_strings_in_arithmetic It makes no sense to keep a landmine there: let's get rid of it, instead of empowering it further (and breaking BC too, while doing so). Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On Sun, Mar 1, 2020 at 10:23 PM Rowan Tommins wrote: > Hi all, > > Following my thread a couple of weeks ago, I would like to put forward > an RFC to fix some inconsistencies with the behaviour of the ++ and -- > operators: > > https://wiki.php.net/rfc/increment_decrement_fixes > > Note that this RFC focusses on three specific cases which I think could > be considered bugs, but require breaking compatibility: > > 1) Bring the behaviour of decrementing null in line with subtracting 1 > (and with the equivalent increment operator) > 2) Bring the behaviour of incrementing or decrementing true and false in > line with adding or subtracting 1 > 3) Throw the same error when incrementing or decrementing an array as > when adding or subtracting 1 > > I believe the behaviour of strings, objects, and resources, each raise > sufficient extra questions that they should be left to future RFCs where > we can focus on each in more detail. > > Please read the RFC for more detail on what is and isn't proposed. > > Regards, > > -- > Rowan Tommins (n=C3=A9 Collins) > [IMSoP] > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --000000000000631fbe059fdf9cde--