Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104598 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 36373 invoked from network); 6 Mar 2019 12:10:38 -0000 Received: from unknown (HELO mail-io1-f49.google.com) (209.85.166.49) by pb1.pair.com with SMTP; 6 Mar 2019 12:10:38 -0000 Received: by mail-io1-f49.google.com with SMTP id y6so9554755ioq.10 for ; Wed, 06 Mar 2019 00:58:59 -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=D6k4Er4hYgdY6P3LY5EgAag6R6T9ap71dhY+DYZX2js=; b=n+zQACbHZQittRwQjKznoWr6KiflawIJoUkQLVZOEF1LXMmgKcZmSJ9kl55oVib7TP AkuP28HjjfcnzOYNlbYbcl//TPEkufHXkhn0w34kcBTA8xej+EZ+KmvNNfwBjGdEsaoe D2xcwUgSgVYL3i4WL3RZkl5868l/T9BtrwlOdnBcejhj96GsbDZfTPwyP7+jLTc8thu6 D5CFjlgfe3U8hvPkHd2C8FKmWbZ72ytOhQXhgv49KQ9Zv8Z6EiLTS9CfCjZZ8YhCgQsM yoAJKpNPJNW43KyAabLqg2bV4NzOFwjDH72pZ9KGQ1OzCVyPTmFZWXQcwdyNaBhmKqnP aWDA== 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=D6k4Er4hYgdY6P3LY5EgAag6R6T9ap71dhY+DYZX2js=; b=X9LzMI4iRM6FbxLlRhzlY/0VIBgOG8op+/hutK4qCvyGP+8/t63SXnXFMzs2B3uYyu /mTIPyF4qrdsB6ueC59SlirQS1Wg6npdvubs+WxwOp0fc+eDMaiLDbHFROmcfSOGMzzq A8N/7nNACEjgvySmpLIXxdCpdXyooUFfkauBnDlCAo0osa6eupSbM/uuhqOFg9jv3HX1 /7E4kOJV10AZ4UQpgG3W74fBpqCDJRHzBE4JNVTwbEQ3xSPooztZjZOthUCzPH9LJk1Z i5HoDlKrGnKvGpcNpfZvBTqr0tw2UrJgCZ+vZglcR1brxEFssnneeeyAKhTz3JJZTMFi rH7Q== X-Gm-Message-State: APjAAAVTzHM0g9VHFqAT4HKtRP9HYsMvUCHIxD09M89mHTTfm9mTPfNs e+oPUR5LqxDmsU1bu0FUF0TRUT5rjQbxG5HYBy4Bew== X-Google-Smtp-Source: APXvYqz4iN9yi5KjfKxwBZKtWKXJLXCP/omI2ePbqFQi0iHbFr9xCgAmOe8EkqoQlOjq2LRgXaBhuaZ8oeWGhj/rQ2M= X-Received: by 2002:a5e:c906:: with SMTP id z6mr2430287iol.47.1551862738830; Wed, 06 Mar 2019 00:58:58 -0800 (PST) MIME-Version: 1.0 References: <40683e93-f8e9-5a8c-9646-31c73c99396f@fischer.name> In-Reply-To: <40683e93-f8e9-5a8c-9646-31c73c99396f@fischer.name> Date: Wed, 6 Mar 2019 09:58:39 +0100 Message-ID: To: Markus Fischer Cc: PHP internals Content-Type: multipart/alternative; boundary="00000000000049cc7a05836933a2" Subject: Re: [PHP-DEV] [RFC] Permit trailing whitespace in numeric strings From: nikita.ppv@gmail.com (Nikita Popov) --00000000000049cc7a05836933a2 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Mar 6, 2019 at 7:41 AM Markus Fischer wrote: > Hello, > > On 06.03.19 01:16, Andrea Faulds wrote: > > https://wiki.php.net/rfc/trailing_whitespace_numerics > > > > I expect this should be an uncontroversial proposal, but maybe I'm > > jinxing it there. I hope you all like it. :) > > > > Thanks to Nikita for reminding me it existed and thus motivating me to > > pick it up again. Also thanks to Nikita for suggesting a potential > > follow-up RFC, and also making the =E2=80=9CSaner string to number comp= arisons=E2=80=9D > > RFC, both providing additional impetus for me to finally clean this up > > and put it to discussion. > > Hmm, my first reaction would be the opposite. > > For all the changes which happened during the years, PHP got stricter; > this would make it more lax. > > I know this is totally not the goal of the RFC, by my feeling is if we > would change something (ignoring BC break for a sec) that it would be to > actually _remove_ support for leading whitespace =F0=9F=A4=B7=E2=80=8D=E2= =99=80=EF=B8=8F > > - Markus > I'm always a fan of making things stricter, but think that in this particular case there are some additional considerations we should keep in mind. 1. What is more important to me here than strictness is consistency. Either both " 123" and "123 " are numeric, or neither are. Making "123 " numeric is a change we can easily do, because it makes the numeric string definition more permissive and is thus mostly backwards compatible. Doing the reverse change is certainly not compatible and will be a much harder sell. 2. I believe that a large part of the motivation here is that by making the numeric string definition slightly more lax (in a consistent manner), we can make *other* things more strict, because this essentially eliminates the only "somewhat reasonable" case of trailing characters. The RFC already mentions two of them: a) We can hard reject "123foo" inputs to "int" arguments (and some other places). Currently this is allowed with a notice. I think if we resolve the trailing whitespace question, then there cannot be any reasonable opposition to this change. b) My own RFC on number to string comparisons would benefit from this. From initial testing it has surprisingly little impact, but one of the few cases that turned up was this comparison with a string that had trailing whitespace. Personally I think both of those changes are a lot more valuable than a stricter numeric string definition without leading/trailing whitespace. Regards, Nikita --00000000000049cc7a05836933a2--