Hello Guile hackers,

In the last release, a procedure called 'alist->hash-table' was
introduced to provide a convenient way to convert an alist into a hash
table.

  (use-modules (ice-9 hash-table))

  (define myhash
    (alist->hash-table
     '(("parrots" . "nuts")
       ("monkeys" . "bananas")
       ("cats" . "fish"))))

I think that it would be even more convenient to build a macro on top
of this to provide a declarative hash table constructor.  A simplistic
example:

  (define-syntax-rule (hash-table (key value) ...)
    (alist->hash-table `((key . ,value) ...)))

  (define myhash
    (hash-table
     ("parrots" "nuts")
     ("monkeys" "bananas")
     ("cats" "fish")))

IIRC, hash table macros are a bit of a controversial topic, but I
think that previous discussions were about a reader macro.

Thoughts?

- Dave

Reply via email to