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