[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Simple hash table macro
From: |
Thompson, David |
Subject: |
Simple hash table macro |
Date: |
Tue, 7 Oct 2014 14:32:33 -0400 |
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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Simple hash table macro,
Thompson, David <=