Discussion List Archives

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CIF-JSON draft 2017-05-08

John,thanks for the historical perspective, it explains a lot.I think that this and the discussion about equivalence of looped andnot-looped values made me finally understand the CIF format.
>> 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.
Yes, I also wrote a numb parser as part of CIF-parsing library:https://github.com/project-gemmi/gemmiBTW I considered using existing parsers, including cif_api, but in theend I decided that it's better to write a new one in C++11. The cifparsing part with Python bindings is <1KLOC. And thanks to the toolsused (C++11 compiler and a library named PEGTL) it happens to be oneof the fastest parsers without any clever optimizations. About 3xfaster than cif_api in the syntax validation mode. (it's not relevanthere but I couldn't resist)
Still, I think that those who will work with JSON format will see itas unfortunate that the numbers are not given to them ready to use.
That said, and after writing too much, I agree that with theseconstraints having numbers as strings may be the best solution.
Cheers,Marcin_______________________________________________cif-developers mailing listcif-developers@iucr.orghttp://mailman.iucr.org/cgi-bin/mailman/listinfo/cif-developers

Reply to: [list | sender only]
International Union of Crystallography

Scientific Union Member of the International Science Council (admitted 1947). Member of CODATA, the ISC Committee on Data. Partner with UNESCO, the United Nations Educational, Scientific and Cultural Organization in the International Year of Crystallography 2014.

International Science Council Scientific Freedom Policy

The IUCr observes the basic policy of non-discrimination and affirms the right and freedom of scientists to associate in international scientific activity without regard to such factors as ethnic origin, religion, citizenship, language, political stance, gender, sex or age, in accordance with the Statutes of the International Council for Science.