* Problems with JSON null
@ 2019-01-02 14:31 John Cowan
2019-01-02 23:32 ` Aleix Conchillo Flaqué
0 siblings, 1 reply; 2+ messages in thread
From: John Cowan @ 2019-01-02 14:31 UTC (permalink / raw)
To: Aleix Conchillo Flaqué, guile-user
In the current version of guile-json, JSON null is represented internally
as #nil. Because of the magic behavior of #nil, this causes certain
problems when trying to discriminate between various internal JSON
representations. For example, the programmer will expect (list? j) to
detect a JSON object and (null? j) to detect an empty JSON object. But
these type discriminators are not correct, because they will also return #t
on #nil. So one must write unidiomatic things like (or (pair? j) ((eq? j
'())) instead of (list? j).
I suggest (even though it is yet another breaking change) switching to the
Scheme symbol null. This is portable, printable and rereadable, and not
subject to the above problems.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Problems with JSON null
2019-01-02 14:31 Problems with JSON null John Cowan
@ 2019-01-02 23:32 ` Aleix Conchillo Flaqué
0 siblings, 0 replies; 2+ messages in thread
From: Aleix Conchillo Flaqué @ 2019-01-02 23:32 UTC (permalink / raw)
To: John Cowan; +Cc: guile-user
On Wed, Jan 2, 2019 at 6:31 AM John Cowan <cowan@ccil.org> wrote:
>
> In the current version of guile-json, JSON null is represented internally as #nil. Because of the magic behavior of #nil, this causes certain problems when trying to discriminate between various internal JSON representations. For example, the programmer will expect (list? j) to detect a JSON object and (null? j) to detect an empty JSON object. But these type discriminators are not correct, because they will also return #t on #nil. So one must write unidiomatic things like (or (pair? j) ((eq? j '())) instead of (list? j).
>
> I suggest (even though it is yet another breaking change) switching to the Scheme symbol null. This is portable, printable and rereadable, and not subject to the above problems.
Hi John,
thanks for reporting this. The best way is to report it through github
(still there...) issues
(https://github.com/aconchillo/guile-json/issues), it's easier track,
reference commits, etc.
I think this change makes sense. I just checked and it's how Racket
does it probably because of the reasons you mentioned. Not too worried
about the breaking change this time, it's not that controversial.
If you don't mind I'd really appreciate if you could file a bug on the
link above and we can continue the discussion there.
Thank you!
Aleix
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-01-02 23:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-02 14:31 Problems with JSON null John Cowan
2019-01-02 23:32 ` Aleix Conchillo Flaqué
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).