guile-user
[Top][All Lists]
Advanced

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

Re: guile-json 2.0.0 released


From: rain1
Subject: Re: guile-json 2.0.0 released
Date: Wed, 19 Dec 2018 19:17:45 +0000
User-agent: Roundcube Webmail/1.3.6

On 2018-12-19 18:14, Aleix Conchillo Flaqué wrote:
On Wed, Dec 19, 2018 at 2:48 AM Ludovic Courtès <address@hidden> wrote:

Hi Aleix,

Aleix Conchillo Flaqué <address@hidden> skribis:

> Any comments on the discussion between alist/vector vs
> hash-tables/list? How hard would it be for Guix to change to the
> alist/vector approach? I'm just considering options and would like
> input from anyone who uses guile-json, specially Guix who's probably
> the biggest user.

I sympathize with David’s comments and would have been happy keeping the
ability to pass alists as inputs.  :-)


Yes, me too. The problem was that guile-json was broken, since there
was no way to distinguish json arrays (lists) from json objects
(alists) and the code that guile-json had was doing the wrong thing.

I haven’t checked but IIUC quite a bit of code in Guix would have to be
modified to use ‘alist->hash-table’.

As for vectors vs. lists, I suppose Scheme vectors in theory correspond
directly to JS arrays (O(1) access), so that’d be an argument in favor
of using vectors on the Scheme side. However vectors in Scheme are less convenient than lists, as John noted, and I’m guessing that often lists
are good enough.  Tricky!


My guess is that most of the time people build objects with JSON so it
seems logic to map them to the most convenient way to represent that
in Scheme which would be alists.

So, I'm really considering switching to alists for objects and vectors
for arrays.

Thanks!

Aleix

Yes

scheme arrays <-> json arrays
scheme alists <-> json objects

seems like a good choice. it is a bijection, nothing clashes or overlaps and everything has a literal syntax.

It will mean we have to use vector-ref/vector-map instead of car/map and stuff, but I think that's fine.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]