Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104963 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 15657 invoked from network); 27 Mar 2019 13:34:43 -0000 Received: from unknown (HELO mail-ed1-f43.google.com) (209.85.208.43) by pb1.pair.com with SMTP; 27 Mar 2019 13:34:43 -0000 Received: by mail-ed1-f43.google.com with SMTP id x10so13450323edh.11 for ; Wed, 27 Mar 2019 03:28:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=L/NKbT8Si+5SA/bDGjFSiZzJVK/0eKNIsarsTHLpbxo=; b=f7luJJWTFu9ZvV9syc5+9yrA+N/DSigbtQOq/wwjKm6wUpU6QXKM/KIgisd7bsB7I8 XFNUFQ3x8ZajD8aVLBlbrmyztDtVlyLiYZSo7WeCHydYF/hSbDmDMRZyY6a8xwpgeu/n j1MKG3Yms8xXAXDK8nE4Y7hGSvXXvQVOJVOICK28Tb4Hp0RFXmUuUbx7s3CUOoU6kARR kHI987kHkg0B5x0vcdUmPjmeODAvl3oiXJoCEAYUKF6nWBSF0d3acHQhpIEP9L8Pf6lL /lVmKfrQGom5rL09EcU5Qr46vCo/6l6awRMTkXkXSiOMDIV4xFGcocvJBf0yt3Z9iB/L iSeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=L/NKbT8Si+5SA/bDGjFSiZzJVK/0eKNIsarsTHLpbxo=; b=ZQQTUOQGCtT9YGGqZ/VCoXWb1J4DPp3EN5qVfRJdpNW6+8D4qeylZi3pQZqA7WkuVO q3afzu3fPlhdbyEfdcUKDWdSDSLgpt6qJ4PIRmzf7mxO5L1ellQIBGFoQpPQS4g4qmzu /4CIsBoBIfsq2HMyiMIlEUa/j6T1DIix3S4+7tSxv+2cY0Lm204mMuL2erjGYZedg7EX ZInIhxGk+KltHA5jRG8qfTj7pklZeuR0SzlO3IhB2sHuZ2VeeX37Cl61sP1mc0MAFBEg 0mfE6iMWPCOxEE5TQ82Z9ba3d3PJScd4TuYueTTV8jkjdT+pSSjwwL7nXwqQsSEyt3dR YvJQ== X-Gm-Message-State: APjAAAVcSom7UDwDQlbvox3QFrw8a25OCtxdBUOB/yOZRzP52UwEGMk+ V33VmBSLtwukX1YFyjvlKTo= X-Google-Smtp-Source: APXvYqwfeMmFLC2nB0zm9qbpVPU/Uvnk4xvcyaAo4f8n0Fhv0lIgp/heZnqjnrRl8wfz+C2J/4ekbA== X-Received: by 2002:a50:a4ab:: with SMTP id w40mr20425673edb.281.1553682499850; Wed, 27 Mar 2019 03:28:19 -0700 (PDT) Received: from [192.168.0.63] (84-75-30-51.dclient.hispeed.ch. [84.75.30.51]) by smtp.gmail.com with ESMTPSA id o60sm7068207edd.95.2019.03.27.03.28.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Mar 2019 03:28:18 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) In-Reply-To: Date: Wed, 27 Mar 2019 11:28:17 +0100 Cc: Rowan Collins , PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: <6C077569-A049-422B-A4CD-6EE5F8DEC388@gmail.com> References: To: Benjamin Morel X-Mailer: Apple Mail (2.3445.102.3) Subject: Re: [PHP-DEV] [RFC] Permit trailing whitespace in numeric strings From: claude.pache@gmail.com (Claude Pache) > Le 27 mars 2019 =C3=A0 00:09, Benjamin Morel = a =C3=A9crit : >=20 > =08- I would also strongly suggest that 2 strings are always compared > byte-by-byte; IMO it does (*somehow*) make sense that 42 =3D=3D = "42.0", but it > DOES NOT make sense that "42" =3D=3D "42.0". (...) There are many ways to obtain numeric data in the form of a string from = external sources (HTML form, database, CSV, ...) and even internal = sources (bcmath, ...)=E2=80=94and note that, even when such numerical = data may have a decimal part, it does *not* mean that they are = imprecise. It is a well-known feature that you can work with such data = without previously converting it explicitly to some number type. That = works pretty well in PHP (well, except that you get intermittent obscure = bugs when some third-party code in the same thread plays with = setlocale(), but that's another story...) If we cease to compare numeric = strings numerically, I expect that much code will begin to break more or = less subtly, and will need to be thoroughly reviewed in order to be = corrected. We must not change that. The core issue is that =E2=80=9C=3D=3D=E2=80=9D is fundamentally = ambiguous: should it compare as number, as string, as reference, ...? If = we were to redesign PHP from scratch, we may decide other semantics than = the current one (e.g., use distinct operators for comparing numerically = and textually, as does Perl). But where we are now, the best thing to do = is to follow the common wisdom: If you want to compare strings as = strings, just use =E2=80=9C=3D=3D=3D=E2=80=9D. Or strcmp. =E2=80=94Claude