* cannot compile: srfi-10 define-reader-ctor 'hash '#,(
@ 2014-07-04 12:30 Jan Nieuwenhuizen
0 siblings, 0 replies; only message in thread
From: Jan Nieuwenhuizen @ 2014-07-04 12:30 UTC (permalink / raw)
To: guile-devel
[-- Attachment #1: Type: text/plain, Size: 1279 bytes --]
Hi,
The attached hash.scm works fine with guile-1.8. With Ubuntu 14.04's
guile-2.0.9 and latest GIT master
5ded849 Convert slot allocation to use intsets
I do get output but compilation fails:
$ guile ./hash.scm
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;; or pass the --no-auto-compile argument to disable.
;;; compiling /home/janneke/vc/verum/development/language/asd/./hash.scm
;;; WARNING: compilation of /home/janneke/vc/verum/development/language/asd/./hash.scm failed:
;;; ERROR: unknown hash-comma tag hash
cat
Is this a bug in the documentation, in guile, or ...?
I need to produce a json file from a guile tree that currently
looks like
((event0 (state (var . value) ...) (trace (loc0 loc1 ...))) ... )
contents of the tree are symbols and numbers. I hacked guile-json to
grok and produce symbols too. So far so good for lists.
However, json wants hash maps. SRFI-10 hash looked like a nice ascii
data exchange format for hash maps. (I would like to have pretty-print
use that notation too, as an alternative for the opaque
#<hash-table b87480 0/31>
I get a suspicious feeling that I'm doing something very wrong if no one
else is using this, please enlighten me?
Greetings,
Jan
[-- Attachment #2: hash.scm --]
[-- Type: application/octet-stream, Size: 467 bytes --]
(use-modules (srfi srfi-10))
(define-reader-ctor 'hash
(lambda elems
(let ((table (make-hash-table)))
(for-each (lambda (elem)
(apply hash-set! table elem))
elems)
table)))
(define (animal->family animal)
(hash-ref '#,(hash ("tiger" "cat")
("lion" "cat")
("wolf" "dog"))
animal))
(display (animal->family "lion"))
(newline)
[-- Attachment #3: Type: text/plain, Size: 154 bytes --]
--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.nl
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-07-04 12:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-04 12:30 cannot compile: srfi-10 define-reader-ctor 'hash '#,( Jan Nieuwenhuizen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).