[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Reply to: [list | sender only]
RE: CIF-JSON draft 2017-05-08
- Subject: RE: CIF-JSON draft 2017-05-08
- From: "Bollinger, John C" <John.Bollinger@xxxxxxxxxx>
- Date: Thu, 11 May 2017 14:19:54 +0000
- Accept-Language: en-US
- authentication-results: iucr.org; dkim=none (message not signed)header.d=none;iucr.org; dmarc=none action=none header.from=STJUDE.ORG;
- DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=SJCRH.onmicrosoft.com; s=selector1-stjude-org;h=From:Date:Subject:Message-ID:Content-Type:MIME-Version;bh=SMoTCi7CWorF7ebu/mxclLpifUvmTc4DiK0Yyv5Yj3g=;b=qdkHJmwUwsXxhfXxDMYfu1zK/NEvLQC1VxJ55mv+8KgjypSs0/UJtCTyuCx+ClrjWgzjtwfBMUvf1ljNu97moIPvUpHGjYEWCtcSd8QHib2qVNMWDrCngWqQ2VqHxGMD+Bau1+OOPB3OD2MZYxwm82m1qT4ohETmWrvA37hsD+o=
- In-Reply-To: <CACaHzQX2XURonZEb1gNyE8sqpMV72EN10SXx9=xOPs6oLR-xcQ@mail.gmail.com>
- References: <CAM+dB2cwoCG6LhPUePRup_hQtM9mXqwL4tULTPf-WGwJGtKrOA@mail.gmail.com><MWHPR04MB051220BFF5C7093CD86702CCE0EE0@MWHPR04MB0512.namprd04.prod.outlook.com><CAF_YUvW=i0XjfzmgA=m03a=X4Y03+FfH8_TAZ2dNPVAhCmuy5w@mail.gmail.com><MWHPR04MB0512E4FA07327A5E9103106CE0EE0@MWHPR04MB0512.namprd04.prod.outlook.com><CACaHzQVez_WUma3z2mAXYroiJtEDtxaUAS-n0Noz-R=nPBTF+w@mail.gmail.com><MWHPR04MB05120B2E2061754ABEBED31AE0EE0@MWHPR04MB0512.namprd04.prod.outlook.com><CACaHzQXKMAqo97iZ6ZdHP_yFhRVKiEBsyMbHZxkBxKwPPcc7LA@mail.gmail.com><MWHPR04MB0512A0D165506326550ED871E0EF0@MWHPR04MB0512.namprd04.prod.outlook.com><CAM+dB2fyQe2KSNRv-+q=Sq3NFWSCK72kBTsUiiJfeSa=PQfvNQ@mail.gmail.com><CACaHzQXxiB=eACzuxT+bqmYyCmcVa-ZABkKOLzm3C5-53xYFvA@mail.gmail.com><CAM+dB2d9G9Hxoz2BToMoVPRdY9_kDvjRBAuJaSgzFAw26fDBtA@mail.gmail.com><CACaHzQX2XURonZEb1gNyE8sqpMV72EN10SXx9=xOPs6oLR-xcQ@mail.gmail.com>
- spamdiagnosticmetadata: NSPM
- spamdiagnosticoutput: 1:99
On Thursday, May 11, 2017 3:18 AM, Marcin Wojdyr wrote: > When I started experimenting with CIF parser a few months ago I noticed that some programs (I think cif2cif was one of them) just treat what looks like a number as a number, ignoring the ambiguity left in the CIF spec. But this indeed would not be fully spec conforming. Forget about my previous email. Historical Notes: The 1991 CIF paper specifies that data values should be interpreted as numbers if they are presented unquoted in a form that _starts_ like a number. Much CIF software from around that time applied that rule, and some of that software persists today. I've always supposed that that scheme was chosen for the convenience of software authors, and I've long wondered whether it might have been primarily a characterization of the actual behavior of a particular early parser. Certainly line-length limits and the text-block syntax cater to the characteristics of Fortran I/O. Regardless, although that approach puts the onus on CIF writers to quote string values where necessary to avoid them being misinterpreted as numbers or almost-numbers, doing so did not emerge as a consistent practice. Moreover, data items came into common use whose values are strings that can take numeric-like form. That combination made the implicit data typing approach unfeasible. That left relying on prior or external information about data items to determine how to interpret their values, and that is basically where we are today. The needed information is a key part of items' definitions in the relevant dictionary, and CIF 1.1 in fact specifies that that is the source from which it should be drawn. ITvG section 2.2.5.2 contains a discussion of this topic. As ITvG observes, however, it may be that CIF software has to handle values for items for which it has no definition to draw upon. ITvG suggests a strategy in such cases of interpreting values as numbers if they can successfully be parsed as numbers, but although that's a stronger condition than the one given in the 1991 paper, it is not fundamentally any better. This is one of CIF's historic weak areas, rearing its ugly head again in our present discussion. >> The consumer of the JSON, on the other hand, will know which of the >> datanames that it cares about are numeric and perform the conversion >> (as per CIF rules, I don't know if the C++17 standard is relevant here). > > I meant that there is no simple way to a write numb parser in C/C++ otherwise. I suppose you were observing that conventional CIF numeric format is locale-insensitive, but the C standard library's `strtod()` is locale-sensitive, and the current locale on which it relies is a process-wide property. Indeed, if you want your C program to parse CIF numeric format in a manner that is both thread-safe and correctly locale-insensitive then you need either to do at least a bit more work or to rely on a suitable third-party library, such as the CIF API. How simple that is is a matter of opinion, I guess. Before the CIF API, I had written parse functions for CIF numeric format at least twice before, in C and Fortran, and maybe in Java as well. Cheers, John ________________________________ Email Disclaimer: www.stjude.org/emaildisclaimer Consultation Disclaimer: www.stjude.org/consultationdisclaimer _______________________________________________cif-developers mailing listcif-developers@iucr.orghttp://mailman.iucr.org/cgi-bin/mailman/listinfo/cif-developers
Reply to: [list | sender only]
- Follow-Ups:
- Re: CIF-JSON draft 2017-05-08 (Marcin Wojdyr)
- References:
- CIF-JSON draft 2017-05-08 (James Hester)
- RE: CIF-JSON draft 2017-05-08 (Bollinger, John C)
- Re: CIF-JSON draft 2017-05-08 (Robert Hanson)
- RE: CIF-JSON draft 2017-05-08 (Bollinger, John C)
- Re: CIF-JSON draft 2017-05-08 (Marcin Wojdyr)
- RE: CIF-JSON draft 2017-05-08 (Bollinger, John C)
- Re: CIF-JSON draft 2017-05-08 (Marcin Wojdyr)
- RE: CIF-JSON draft 2017-05-08 (Bollinger, John C)
- Re: CIF-JSON draft 2017-05-08 (James Hester)
- Re: CIF-JSON draft 2017-05-08 (Marcin Wojdyr)
- Re: CIF-JSON draft 2017-05-08 (James Hester)
- Re: CIF-JSON draft 2017-05-08 (Marcin Wojdyr)
- Prev by Date: Re: CIF-JSON draft 2017-05-08
- Next by Date: Re: CIF-JSON draft 2017-05-08
- Prev by thread: Re: CIF-JSON draft 2017-05-08
- Next by thread: Re: CIF-JSON draft 2017-05-08
- Index(es):