RFC: std.json sucessor

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Fri Aug 22 11:08:40 PDT 2014


On 8/21/2014 3:35 PM, Sönke Ludwig wrote:
> Destroy away! ;)

Thanks for taking this on! This is valuable work. On to destruction!

I'm looking at:

http://s-ludwig.github.io/std_data_json/stdx/data/json/lexer/lexJSON.html

I anticipate this will be used a LOT and in very high speed demanding 
applications. With that in mind,


1. There's no mention of what will happen if it is passed malformed JSON 
strings. I presume an exception is thrown. Exceptions are both slow and consume 
GC memory. I suggest an alternative would be to emit an "Error" token instead; 
this would be much like how the UTF decoding algorithms emit a "replacement 
char" for invalid UTF sequences.

2. The escape sequenced strings presumably consume GC memory. This will be a 
problem for high performance code. I suggest either leaving them undecoded in 
the token stream, and letting higher level code decide what to do about them, or 
provide a hook that the user can override with his own allocation scheme.


If we don't make it possible to use std.json without invoking the GC, I believe 
the module will fail in the long term.


More information about the Digitalmars-d mailing list