From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Improving JSON pretty printing, how to represent floats? Date: Fri, 05 Apr 2024 18:34:42 +0300 Message-ID: <865xwv6cx9.fsf@gnu.org> References: <87msq8w2zm.fsf@gmail.com> <86bk6o56np.fsf@gnu.org> <87bk6o55ci.fsf@gmail.com> <867chc5526.fsf@gnu.org> <877chc5417.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22516"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: =?utf-8?Q?G=C3=A9za_Herman?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Apr 05 17:35:35 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rslbK-0005aY-Dp for ged-emacs-devel@m.gmane-mx.org; Fri, 05 Apr 2024 17:35:34 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rslab-00074e-I7; Fri, 05 Apr 2024 11:34:49 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rslaZ-00074J-OQ for emacs-devel@gnu.org; Fri, 05 Apr 2024 11:34:47 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rslaZ-0005sF-8o; Fri, 05 Apr 2024 11:34:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=tq4wc/A351QkVd6qsfu3ry3JHKwayVytSh6r1msNVzI=; b=gA/VCSlVe0FGUXgSsQsC tVGYBghRlrRH4xR3R1RnsaLl1KYUtaKYuz68rYThqC5nwwNmmLc/Cv0PYOwc5YwSP21bGsBlpv6er u9l8jdXOngXmKi9B4Q4pSuplwXlqcVZqL0+sLVJwDh8RJ51VvcJLnslx0vy4M8yaxctkW/Pq+Y+fj lkvegOnF5qn3wO2WwhS8y70FUPdUTZq06e1mM6CKkTCQ8vy81uvX5z6k5yi/98iUvx9Jd3N6U51Yt jm0UHzqi67nwU8jtho6I64SjKvc5ZNi2Al60gK0LRbvLsX6PH7Qs2Y+lpfmsMOOaAWAMkl43kXAOr fJbjNb86l7zTSQ==; In-Reply-To: <877chc5417.fsf@gmail.com> (message from Herman, =?utf-8?Q?G?= =?utf-8?Q?=C3=A9za?= on Fri, 05 Apr 2024 15:16:44 +0200) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:317554 Archived-At: > From: Herman, Géza > Cc: Géza Herman , > emacs-devel@gnu.org > Date: Fri, 05 Apr 2024 15:16:44 +0200 > > > Eli Zaretskii writes: > > >> You mean the 64-bit binary format. IEEE-754 describes more > >> formats which have more precision, and also there are more > >> formats used in practice than what IEEE-754 describes. > >> > >> Plus, I don't think that the JSON standard mandates IEEE-754 > >> numbers. It just describes numbers, so I think it's good > >> behavior to not change numbers during formatting. > > > > The fact that Emacs supports IEEE-754 on almost all platforms is > > prominently documented in the ELisp reference manual, see the node > > "Float Basics" there. > > I don't think it's relevant here. It is relevant to me, because a float in a JSON has a meaning, it isn't just a string. If you want strings, use strings, and then they will not be changed by pretty-printing. > If I reformat a JSON, it should really be a formatting operation, it > shouldn't matter what kind of floating point numbers a platform > supports. Any JSON that uses a float which needs more than 64 bits of precision is not portable to most of today's machines. I'm not interested in complicating Emacs to support imaginary use cases, sorry. When enough important platform switch to more bits of precision, so will we, and then we will be able to have more digits in floats -- but even then the number of significant digits will be finite. > What if I open a .json file because I want to edit it a little bit > (renaming some members, etc.), but then I realize that the format of > the json is bad, so I reformat it. But I want to maintain the > precision, because I intend to use the .json in some other software > which supports arbitrary floating point precision. Well, you can't. It makes no sense. Floats are objects with certain semantics, they are not just arbitrary strings.