Some questions and comments on the srfi and its reference implementation Alejandro Santana 01 Mar 2021 06:27 UTC
I am writing an implementation of this srfi intended for gambit, but code is mostly r7rs. link: https://github.com/alejsan/gambit-srfi-180-json I have a few questions and comments. 1. Should the generator produced by json-generator close over the current values of json-nesting-depth-limit and json-number-of-character-limit when it is created? Consider the example: ;; generator created, default parameter values of +inf.0 (define gen (with-input-from-string "true" json-generator)) ;; generator used, reference implementation does not raise an error (parameterize ((json-number-of-character-limit 1)) (gen)) 2. Why is the port-or-accumulator argument to json-accumulator required? I think the returned accumulator should default to writing to the current-output-port just like json-write does. I believe the following are errors in the reference implementation: 1. The reference implementation of json-generator accepts ONLY an input-port and does not accept a character generator as its argument. 2. The reference implementation of json-accumulator accepts ONLY an accumulator and does not accept an output-port as its argument. 3. In the reference implementation the accumulator produced by json-accumulator expects its input to be pairs such as (cons 'json-value 10) or (cons 'json-structure 'array-start). It does not accept the output of generators produced by json-generator.