From: Jan Nieuwenhuizen <janneke@gnu.org>
To: guile-devel@gnu.org
Subject: cannot compile: srfi-10 define-reader-ctor 'hash '#,(
Date: Fri, 04 Jul 2014 14:30:47 +0200 [thread overview]
Message-ID: <87y4w9jog8.fsf@drakenvlieg.flower> (raw)
[-- 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
reply other threads:[~2014-07-04 12:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y4w9jog8.fsf@drakenvlieg.flower \
--to=janneke@gnu.org \
--cc=guile-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).