2014-08-13 21:59 GMT+02:00 Jan Nieuwenhuizen <[email protected]>: > Ludovic Courtès writes: > >> The problem is that SRFI-10 itself does not specify an external >> representation for hash tables, nor does Guile. Thus this patch cannot >> be applied. > > Yes, I understand that...Still, "wouldn't it be nice" if Scheme/Guile > had something that javascript has, in JSON hash tables are "simply" > > {"key0": value, "key1": value}
I have been thinking about that issue a lot, and concluded that it wouldn't be "the Scheme way". Scheme already has a nice representation for associactions, namely the assoc lists. However, they are a bit problematic, because they are ordered by nature and hence there's not much one can do with their linear access time. The proper solution, I believe, is to provide some means to create unordered collections (i.e. sets or multisets). Some hints for constructing such collections were given by Daniel Friedman and reminded recently (like 10 years ago ;]) in Guy Steele's talk for Friedman's 60th birthday: http://www.youtube.com/watch?v=IHP7P_HlcBk After that, a paper came out which described that idea in greater detail: http://projects.csail.mit.edu/wiki/pub/JoeNear/FernMonad/frons.pdf Anyway, I think it would be nice to provide a notation for unordered collections in Scheme, so that the associations, written as '{(key . value) ...}, could eventually be optimized and perhaps implemented as hash tables internally in some cases.
