Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103648 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 4363 invoked from network); 29 Dec 2018 03:30:58 -0000 Received: from unknown (HELO mail-pl1-f174.google.com) (209.85.214.174) by pb1.pair.com with SMTP; 29 Dec 2018 03:30:58 -0000 Received: by mail-pl1-f174.google.com with SMTP id u6so10568484plm.8 for ; Fri, 28 Dec 2018 16:02:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=4oyEOuCEwerO5mhr08Y5FeRD9/vXCbXCjFJEvntpIQU=; b=N0vZUuHLnMN/xupI1FBP9K93Fld1UfmhHcrHtMgksSqkNHZbd7TuEkZrB9Pea9r7gk j3UKy0cmqNJbl0tXSL4CczPEqNIFnDeS/epN3Is3U72VGvYRsA0siS3ieP1OQcSTTzOd xHXVZ/68dQoOQ8k60+zcJJdg7CZ1yGUF3NRW3AFyhiApxbuKKQkSsrSrKTVNZP0B5xVs AW7TdqhsZ4quE33AE6JVwpg9aJubxC41Qa9rnN7TAR7EQ1vN5U9eluIPvvA46wU3MSUQ M27Z5BhiR7jjAqIhS+mRr0A/wmG5+6oRlfmmN8O9v1+ykzpoNXZmX8USG7RKU/Uj4jPt bOSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=4oyEOuCEwerO5mhr08Y5FeRD9/vXCbXCjFJEvntpIQU=; b=kg5AHv4BsUcqIvXIax3hmrtMvYRgwk8SfVv/zzpQfFe26Rk4qxAer2UMRaiasK6KS2 6r4UfXSG7XI8hHZvCHMjMY8vITbbUlfRhKOMp3D763ChXfQg5EZjJvFLeaUEDmVwtnbN aMGmsxZYKTZVxh0IkfXtvD/unVbwuDB9ht+RAkMMXeSgyw+1oIwu1qRfomNdOg0VhXmo NpHKZhdwWg0KcBr25sx0Ka1dN+hCLpzLvr/r0eoGDNM9T7VURmdG2s1HHn/7pnV/s3bR En4NRFMx/lIbHnMj+HzvuD2WmTJ6H8SVoEhEAu88NHwkiO+AKdwiblTW8Z8JqkmdIwWp sWQg== X-Gm-Message-State: AJcUukfydRl2IfwBDFvjN5Jeh6QTZ8hTZrYR+n4aeaaabdOM5P1pU58p jzGZeIoJLC+Zh2sBuX815LPq/sXRrQ== X-Google-Smtp-Source: ALg8bN7gn+FywsjjrwmQYVBqqGmOPEuBgVyzdt7wnjkuj6FCILEQykMqws/J2lbj39vL6kM3CP2o4g== X-Received: by 2002:a17:902:9692:: with SMTP id n18mr29902037plp.333.1546041747500; Fri, 28 Dec 2018 16:02:27 -0800 (PST) Received: from Stas-Pro-2016.local (c-24-4-176-254.hsd1.ca.comcast.net. [24.4.176.254]) by smtp.gmail.com with ESMTPSA id g15sm192936726pfj.131.2018.12.28.16.02.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Dec 2018 16:02:26 -0800 (PST) To: "Christoph M. Becker" , internals@lists.php.net References: Openpgp: preference=signencrypt Autocrypt: addr=smalyshev@gmail.com; prefer-encrypt=mutual; keydata= mQMuBE9mqaARCACFSqcGmNunkjQQu3X+yXnTmFeEkvM4JXZTOBdR8aEevNGmmFEfyvjaDjWi 9hcwp4E/lYtC+P7VsVjM1OSX9eq0jC/lGL0ZyRXek+mNy0n5H1NSuTpf9Y18LMqhc4G+RU+L cNiZ9K0DJuOOvNLPxW7OHZguxb3wdKPXNVa2jyRfJAKm2uaJJMT1mTmFT9a0Q8SKr+mUrrJk uG0H2o6SzrKt8Wwoint1eh67zVsJaJtQFchnEZnlawIcqP2yC4nLGR3MkubowxoEBYCZet18 aHVVRbvpG2Qtob8Lu5xrsGbmXymTkHTdpvkfcJFADa8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iXJgCVH8fgpZpR856ulT1q6uCG++CX ubEvip/eJkZl93/84h04KQJwsgOrAh0Om3OePRn8Pr+++0LNS0EL8uX/YHeTOGOnnmTqYTey SBVFdov6L4mepddfjekicKQqhL7mZh/xuq29JijT0uNNX8v4vDWQDu5dlAcdd+uB3gcXMD/P ginD11zp+6wtrWCm/+yBqpvDwXQX5PGUnwvbRfl7Ay3MmwmoXiecZMg0dwTSc7e0lhB4HGRH ZdBMJB4rHUVGdzqujK/ctOvrAAMFB/0Utb76Qe6sCMlHxVAmeE/fbo7Pi05btZ/x01r67dHf aMSP0riCKJ7M0OW+jAXtu9+z/BVnYisW67WWfxl2cS5tZDgiHgJARXWUOO72+sScHP8KQmTl 1z16gyKbwY3SmyBkwcpOL35nhUWNLy93syPoY6sZUTikr2bZYukHDQ33XBPs4e6MbWKfsa9q aVmnlOF3k5UqChjutfHaEa4Q7VP4wBIpphHBi9MI16oJIzzBPbGl2uoedjwiZ6QeQZnSuOVY ZxU2d3lRA8PrtfFN1VSlpEm/VcAvtieHUYWHN0wOu+cp3Slr5XJVNjTjJhl28SlinMME54mK AGf2Ldr/dRwXiGEEGBEIAAkFAk9mqaACGwwACgkQL3lWvF2gS126EQD/VVd3FgjLKglClRQP zdfU847tqDK4zJjbmRv5vLLwoE0A+wbrQs7jVGU3NrS0AIl5vUmewpp2BKzSkepy23nWmejw Message-ID: Date: Fri, 28 Dec 2018 16:02:26 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.3.3 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Inconsistent float to string vs. string to float casting From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > Regarding the decimal separator (aka. decimal point), the behavior of > casting float to string is inconsistent with casting string to float. > While the former regards the current locale, the latter always expects a > decimal point regardless of the locale. This breaks round-trips for > locales which use something else than a dot as decimal separator (e.g. > German, which uses a comma), for instance: That may be inconvenient, but changing it now would be way worse IMHO. Ideally, system conversions would return well-defined result (locale as a global is a *horrible* idea which can only be explained by it's genesis in simpler times where most of the software was written to be run in one specific environment and user putting a pack of punch cards into the reader would only need them to be processed in one locale) and for configurable outcome you'd use functions that receive explicit parameters. > As for me, the question is not *if*, but rather *when* and *how* this > inconsistency should be resolved. Regarding the *when*, it seems to me If you mean that loading "0.3" from string would suddenly stop working in Germany, then never. If you mean that (string)0.3 would return "0.3" and not "0,3" in Germany, then again I'd say probably never, though very slightly less confidently. Those people who didn't want it already have code to deal with it, and those that wanted it would have their unit tests crash and burn and their data pipelines blow up. I think it's a very bad idea to change such things, which would create hundreds of year-persons of headache to anybody daring to upgrade. I understand it's a bad situation, but I think the right exit of it is to tell people that want predictable roundtrip results to use specific number conversion functions, and not exchange one mess to another, BC-breaking and havoc-wreaking, mess. I agree that the right thing to do would be to have (string)0.3 to always use dot and never use locale (did I mention I think global locale is a horrible idea?) but that ship has sailed. I don't see a use case that would be well served by breaking the BC now. -- Stas Malyshev smalyshev@gmail.com