Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85541 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 23510 invoked from network); 30 Mar 2015 08:05:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Mar 2015 08:05:34 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.42 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.218.42 mail-oi0-f42.google.com Received: from [209.85.218.42] ([209.85.218.42:35125] helo=mail-oi0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9D/51-15027-CC309155 for ; Mon, 30 Mar 2015 03:05:33 -0500 Received: by oiag65 with SMTP id g65so121296426oia.2 for ; Mon, 30 Mar 2015 01:05:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=mdjFaYPs/Bo5qxt1CrQ/e3B3/EH/rgZXmsJquGcY18s=; b=DVTR4tOlDYhGeJIV/H0oPphulj8XMPFcDvzR011p0Q6wOq5Zyz/qRIKCpNV18qn6aQ 0tqaoV5vnDd3537YxVI2Slle4ZhPibImomAP1eQ+pkEOqcVbE7EdsoeZigYeatY8Zzyc yTuNSFMvPxZAzgmDNerMb8BPz/Cl5sjkWFWWAlnuMjTqRej8BEJaGJBQUfu/XhJixCwz jKp99IfjWGXGSfHILV/vtypk796mW0e+pdjpGmBPHBD01C5mWsX00Ltp0qgpbGMDkNaM Pzkq8jBlzD1xfqln2s1J2f1TYRfaPXlYjLnYnyI/3SrCzvooMJDR+uFdBblhauvgYs9S tPdw== X-Received: by 10.60.57.36 with SMTP id f4mr25568059oeq.6.1427702729929; Mon, 30 Mar 2015 01:05:29 -0700 (PDT) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.202.58.2 with HTTP; Mon, 30 Mar 2015 01:04:49 -0700 (PDT) In-Reply-To: References: Date: Mon, 30 Mar 2015 17:04:49 +0900 X-Google-Sender-Auth: hnUN9wF5iihhukDvxiaoa44sbjg Message-ID: To: Pierre Joye Cc: Jakub Zelenka , PHP internals list Content-Type: multipart/alternative; boundary=089e0149be180ffbbb05127cf20b Subject: Re: [PHP-DEV] JSON float number as string From: yohgaki@ohgaki.net (Yasuo Ohgaki) --089e0149be180ffbbb05127cf20b Content-Type: text/plain; charset=UTF-8 Hi Pierre, On Mon, Mar 30, 2015 at 11:42 AM, Pierre Joye wrote: > On Mon, Mar 30, 2015 at 9:14 AM, Yasuo Ohgaki wrote: > > Hi Pierre, > > > > On Mon, Mar 30, 2015 at 10:54 AM, Pierre Joye > wrote: > >> > >> Same effects but totally unrelated topics. All functions dealing with > >> large external numbers had the same issues, since ever. It has nothing > >> to do with STH. > > > > > > Yes, it is. > > Developers make casting mistakes like this even when they are used to > strict > > typing. > > I understand and this is why I said it is the same symptom. But JSON > or any other external data decoding has nothing to do with STH. It > would be nice to do not clutter this discussion with yet another STH > argument :) As you know, I'm an very unhappy person with the accepted RFC :) Since Zeev closed the vote before the end date, I think we may have a little chance to improve weak mode scalar type hint. i.e. Use Zeev's RFC for weak mode. Anyway, similar issue is not only external but also PHP internal. For example, [yohgaki@dev php-src]$ ./php-bin -r 'var_dump(["999999999999999999999"=>1, 999999999999999999999=>1]);' array(2) { ["999999999999999999999"]=> int(1) [3875820019684212736]=> int(1) } Library that deals with array should use "string" key data type to have correct key for any number even when library expects integer keys. i.e. The library must have "string" type hint for integer key to achieve correct behavior. Database, JSON and array are good examples of confusions. Smart developers will use "string" type hints for these, while less experienced developers will use "int/float" type hints for these. When users have to use both of them, users are forced to casting variable between "string" and "int/float". This makes impossible to write "correct" code. This JSON bug is a proof that this will happen. I just don't see the point to introduce new feature that makes impossible to write correct code while there is good solution. Fortunately, we still have time to address this. Regards, P.S. Does anyone have alternative ideas for this? -- Yasuo Ohgaki yohgaki@ohgaki.net --089e0149be180ffbbb05127cf20b--