Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103670 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 41808 invoked from network); 2 Jan 2019 22:24:22 -0000 Received: from unknown (HELO mail-it1-f193.google.com) (209.85.166.193) by pb1.pair.com with SMTP; 2 Jan 2019 22:24:22 -0000 Received: by mail-it1-f193.google.com with SMTP id m62so42206732ith.5 for ; Wed, 02 Jan 2019 10:57:04 -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=1eLfA0v8/gHQoY1EEGB6iw3VaUbjyWtOjb2lNY1j4RE=; b=sIb0JkSOzvpsUEbdkJNQL+Jv4KX92HhAMWOE0pbxgHuu74Ho+ttFlUuYJVESk5G6qC bYAnATx0x3CcBiYFu4hnyDuFM3wQlMchPsRbziH/M8X14f1vttCQtZime57tF8Ayn/g5 uCgTg0ELsHcyiw5ofW1DycgX1Ld8dnyjITijosKqevWR3NV924zceaYF84mJFq8Kv7UD IZzjXyL2dGNUSAGzTwGzW36yLx1alrp1R1Xel46c4USh/VLZ8ymVRmAsTPt+1bNI/sSR iObIGo24dwvKSdnvGLqDfeMYvnNLPZF5mRIJtIm56vQx/6aOfo7l9rLcIlOdidcHRLTi V4xg== 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=1eLfA0v8/gHQoY1EEGB6iw3VaUbjyWtOjb2lNY1j4RE=; b=rHtqVoZ5rPXO5KWi8v8u4esQ5JSNXMPLNz77C1IOJpao9kCSG1iU+VL02FhYmW1gB8 k81Nws8qvQiQ/h8G+s3Fmzwu1HcSpLHc9iu5lrr/GRumy4qWfamtWr7FNivmqgVMoYJR GYBVt9Vc9x+lqnchLbZQIirg4py202oOYuXwhKurIR95UNVsPiwOOFxlB2fu3gOCC9Iq +KGdVmIrswMP1zhut+zvAiIOl7+fMlxWi1NQUcv8J7uwoq171aJx8AlHACZkr1GF0lXu hMmGsYS1tt3mAcGHRj0WTGFnbx4RjRXbjjLbV6jEbkpzgLDmwSuKd2ms+wuV4cSIb81V 6PUA== X-Gm-Message-State: AJcUukdNCwcG1n8FvQi/W0BDs7CFFlZ8evKLnvV1AA+XHwYAeoUf++7J VdrEogCCoaZWfL6Wq8CODeEviD/dJtfPePqmzSc= X-Google-Smtp-Source: ALg8bN5Xo0FW8OoCxuTANcJBU/tW1pJ60GjmKadjW4ESQN4n3GoSTa7Gb66NS1UO1X9lgVQnzxuNXpcLDM9st2KzdCg= X-Received: by 2002:a24:de87:: with SMTP id d129mr29264302itg.110.1546455423831; Wed, 02 Jan 2019 10:57:03 -0800 (PST) MIME-Version: 1.0 References: <94f5feb8-6589-3a0a-2849-7679cec1858c@gmx.de> In-Reply-To: Date: Wed, 2 Jan 2019 19:56:46 +0100 Message-ID: To: Zeev Suraski Cc: Stanislav Malyshev , "Christoph M. Becker" , PHP internals Content-Type: multipart/alternative; boundary="00000000000032d46c057e7e36b9" Subject: Re: [PHP-DEV] Inconsistent float to string vs. string to floatcasting From: nikita.ppv@gmail.com (Nikita Popov) --00000000000032d46c057e7e36b9 Content-Type: text/plain; charset="UTF-8" On Wed, Jan 2, 2019 at 6:22 PM Zeev Suraski wrote: > > > On Wed, Jan 2, 2019 at 6:11 PM Nikita Popov wrote: > >> On Wed, Jan 2, 2019 at 12:33 PM Zeev Suraski wrote: >> I don't expect this to be a particularly large issue for two reasons: >> >> 1. Not many people use this. I'm sure that there *are* people who use >> this and use it intentionally, but I've only ever seen reference to this >> issue as a bug or a gotcha. >> 2. Even if somebody is using this functionality, the only thing that's >> going to happen is that their number display switches from 1,5 to 1.5. >> That's a minor UX regression, not a broken application. It's something that >> will have to be fixed, but it's also not critical, and for a legacy >> application one might even not bother. >> > > FWIW, neither of these are very convincing for me: > 1. I'm not sure what you mean "not many people use this"? People don't > convert floats to strings? > No, that's not what I meant. Of course, many people convert floats to strings. But the vast majority of them expect to get back a floating point number in the standard format. What I mean is that there are not many people who use float to string conversion with the express intention of receiving a locale-dependent result (and use a locale where the question is relevant). Those are the only people who would be (negatively) affected by such a change. > 2. Perhaps you meant they weren't proactively relying on this behavior, > which could be true - but it doesn't matter whether people were expecting > or otherwise desiring this behavior when they wrote the code. Whatever the > current behavior is - they adjusted for it, and ended up using it, > consequently relying on it. > As said, I'm sure there are people relying on this. What I'm saying is that the number of people who rely on float conversions to *not* be locale-sensitive is vastly, orders of magnitudes larger than the number of people who *do* rely on it being locale sensitive. The only saving grace is that this issue only turns up relatively rarely, because it requires you to explicitly call setlocale, as the locale is not inherited from the environment. Or more likely, you're not going to call setlocale, but discover this wonderful behavior because something else does for entirely unrelated reasons. > 3. I view a UX change as a big deal. As we should in a language that is > very commonly used to create UI. > 4. This could effect not only UX, but also integration code. You could > have PHP output feeding into something else - and suddenly, the format > breaks. With the fix HAVING to be in the other side, no less. > The fix doesn't have to be on the other side. Most likely you'd prefer to fix it on your side by explicitly formatting the float in the desired manner. It's usually the other way around. The current behavior is prone to breaking integration code, because data interchange layers generally do not expect floats to use comma separators. The reason why things don't break quite as terribly as they could is that PHP has introduced a number of workaround over time, as these issues have been reported. That's why you usually don't run into this when inserting float values into a DB query, at least when using prepared statements. This issue is not handled everywhere though (one recent example I remember is passing floats to bcmath) and I don't think that introducing more of these special cases is how we should be approaching this problem. Nikita --00000000000032d46c057e7e36b9--