RFC: std.json sucessor

Sönke Ludwig via Digitalmars-d digitalmars-d at puremagic.com
Mon Aug 25 13:21:02 PDT 2014


Am 25.08.2014 17:46, schrieb "Ola Fosheim Grøstad" 
<ola.fosheim.grostad+dlang at gmail.com>":
> On Monday, 25 August 2014 at 15:34:29 UTC, Sönke Ludwig wrote:
>> By default, floating-point special values are now output as 'null',
>> according to the ECMA-script standard. Optionally, they will be
>> emitted as 'NaN' and 'Infinity':
>
> ECMAScript presumes double. I think one should base Phobos on
> language-independent standards. I suggest:
>
> http://tools.ietf.org/html/rfc7159

Well, of course it's based on that RFC, did you seriously think 
something else? However, that standard has no mention of infinity or 
NaN, and since JSON is designed to be a subset of ECMA script, it's 
basically the only thing that comes close.

>
> For a web server it would be most useful to get an exception since you
> risk ending up with web-clients not working with no logging. It is
> better to have an exception and log an error so the problem can be fixed.

Although you have a point there of course, it's also highly unlikely 
that those clients would work correctly if we presume that JSON 
supported infinity/NaN. So it would really be just coincidence to detect 
a bug like that.

But I generally agree, it's just that the anti-exception voices are 
pretty loud these days (including Walter's), so that I opted for a 
non-throwing solution instead. I guess it wouldn't hurt though to 
default to throwing an exception, while still providing the 
GeneratorOptions.specialFloatLiterals option to handle those values 
without exception overhead, but in a non standard-conforming way.


More information about the Digitalmars-d mailing list