Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104967 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 87586 invoked from network); 27 Mar 2019 18:20:42 -0000 Received: from unknown (HELO mail-io1-f52.google.com) (209.85.166.52) by pb1.pair.com with SMTP; 27 Mar 2019 18:20:42 -0000 Received: by mail-io1-f52.google.com with SMTP id d201so14373889iof.7 for ; Wed, 27 Mar 2019 08:14:22 -0700 (PDT) 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=SlvjQudXwHhibQ+KOfzT5QLEB5Y+ZS+rkSEjMzymF2E=; b=qt6+JIA5kd+6lhKIgVEhBnNW5wv4cVfyJVU81o5KFS5dG9apiNsHYBirlhPDOaRzrQ 182/gZPIw86U6r/7phAc0XUUvIUIedWkKHzg3YI3OywCU+P0Jvy1HYxnYO3TQ4Vnyjn+ 3AuMcqhYFPCOD5UsgbXVpP1UvkQYmUWj1OTS+BjbdLO4jVoX9+apLnwGxV6XvBnrxpIa RGHh/4qVn4JItNtr5T5zrCIznT/5CgpGC1ndfV17dJm7+D+bciB0NXHlJtbaAImsUeLO +fRyzC0O2K1Xu2WVXyB2sOMLDFBFoK1Wv/9n2ArJqe0DIGp93m6PE4W7FCis/9n5o9q+ 0y8w== 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=SlvjQudXwHhibQ+KOfzT5QLEB5Y+ZS+rkSEjMzymF2E=; b=K/niBR2BCYqIg4yUo+OF02/BPAt7IcyPghSAfl2kqEnc2euQ8d1FWhPxgaZqx6Cma7 LBR39g3iS2Y23HKOuixEWe+v6rkZmJhb0l5RW1sOyEyI9Mjlf+wGID0LF/0AsB85Q1pq 3ZG6a7uoj/OCSmvrRo6Z8PUtKPFL3VWePTujYZyrWV78NfXkVE+MkavY8uoo6bmu0W85 H7lQyZnwpL2KZKsIi3ePq027sufVM0LsLQ9h8Cy4pIxQ+8odJYiQPOHiWpVRk4nlLUkt NyfWQzpj0AJKhKhChlKWKYuXjGU7d/uKqyHh/5I1K0r7FsDj565S0CViIKuYiSAaFRbQ dkvQ== X-Gm-Message-State: APjAAAXd+GuD3Bs0vgY1jTtt/M+3TfdRf4eHeD9aKlu02zyU7fmLEm5y yXXGATbEQoNP55BsNoseBZ9yKGs33aQMDPm1XRk= X-Google-Smtp-Source: APXvYqxQqI/5KJT0egr89uu+Cr1uZVHe+vl2Y4rgzv8swGKrqfGYRCIDmchUINke9ijd5NzddvxWwcsxWSnpAn4j1dI= X-Received: by 2002:a5e:dd44:: with SMTP id u4mr26251249iop.44.1553699662099; Wed, 27 Mar 2019 08:14:22 -0700 (PDT) MIME-Version: 1.0 References: <6C077569-A049-422B-A4CD-6EE5F8DEC388@gmail.com> <481CB4EE-599D-4CFE-9F5E-8B04EC2BAB35@gmail.com> In-Reply-To: <481CB4EE-599D-4CFE-9F5E-8B04EC2BAB35@gmail.com> Date: Wed, 27 Mar 2019 16:14:09 +0100 Message-ID: To: Claude Pache Cc: Rowan Collins , PHP Internals Content-Type: multipart/alternative; boundary="0000000000007278e8058514e44d" Subject: Re: [PHP-DEV] [RFC] Permit trailing whitespace in numeric strings From: benjamin.morel@gmail.com (Benjamin Morel) --0000000000007278e8058514e44d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > Isn't this the purpose of Nikic's Saner PHP String comparison RFC? It is, sorry I mixed the discussions here. As I said below, I think that these RFCs would deserved to be merged. > Because boths nikic's and Andrea's RFC go hand in hand. > And probably if both these RFC get accepted a new "stricter numerical string comparison" RFC could see the light banning leading and trailling whitespace I'd rather tackle the whole thing right now, as PHP 8 is a good opportunity for whatever BC break this will cause. Another such opportunity will not happen again before many years. > Arithmetic in JavaScript cannot be used reliably (in general) without converting your data to the proper type, because 1 + 1 gives you 11 if one of the 1s is encoded as string. PHP does a better job in that respect Sure, PHP has the huge advantage here to have a dedicated string concatenation operator, removing any ambiguity around the + operator. This does not mean that we cannot borrow their semantics for string/number *comparison*! Ben On Wed, 27 Mar 2019 at 15:26, Claude Pache wrote: > > > Le 27 mars 2019 =C3=A0 14:29, Benjamin Morel = a > =C3=A9crit : > > > > Thinking about this a bit more, what about following JavaScript > semantics? I find them really good in this respect: > > > > Arithmetic in JavaScript cannot be used reliably (in general) without > converting your data to the proper type, because 1 + 1 gives you 11 if on= e > of the 1s is encoded as string. PHP does a better job in that respect. As= a > result, there is good chance that people (it is at least the case for me) > are more confident to rely (often implicitly) on automatic type conversio= n > between strings and numbers when doing basic arithmetic in PHP than in JS= , > including for comparison of numeric values. > > About leading/trailing whitespaces: usually, numbers encoded as strings d= o > not contain them; so that it may be OK to consider strings containing the= m > as non-numeric if we want. > > =E2=80=94Claude > > --0000000000007278e8058514e44d--