From: Ian Price <ianprice90@googlemail.com>
To: "Sjoerd van Leent Privé" <svanleent@gmail.com>
Cc: guile-devel@gnu.org
Subject: Re: Immutable rnrs hashtable
Date: Mon, 26 Nov 2012 01:07:38 +0000 [thread overview]
Message-ID: <87r4nhb291.fsf@Kagami.home> (raw)
In-Reply-To: <50B2A31B.1070903@gmail.com> ("Sjoerd van Leent Privé"'s message of "Mon, 26 Nov 2012 00:00:43 +0100")
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=iso-2022-jp-2, Size: 2070 bytes --]
Sjoerd van Leent Priv^[$(D+1^[(B <svanleent@gmail.com> writes:
> Hi all,
>
> I might have found an issue using commit
> 06906f370f77cbab520ff0d3c47449526934a9c8 (stable-2.0). I am attempting
> to do a hashtable-copy using rnrs hashtables, and set the mutable flag
> to #:t (according to documentation this should make it immutable, a
> bit odd). I attempted #:f as well. It appears the output hashtable is
> still mutable.
Firstly, according to the R6RS, if the mutable argument is provided, and
is true, then the hashtable is mutable. Otherwise it is immutable.
http://www.r6rs.org/final/html/r6rs-lib/r6rs-lib-Z-H-14.html#node_idx_1200
Secondly, #f or #:f ? #:f is a keyword, and since it isn't #f, is considered a
true value. Therefore, the hashtable should be mutable.
A quick repl transcript
scheme@(guile^[$B!]^[(Buser)> (make-eqv-hashtable)
$10 = #<r6rs:record:r6rs:hashtable>
scheme@(guile^[$B!]^[(Buser)> (hashtable-set! $10 'foo 'bar)
scheme@(guile^[$B!]^[(Buser)> (hashtable-copy $10 #t)
$11 = #<r6rs:record:r6rs:hashtable>
scheme@(guile^[$B!]^[(Buser)> (hashtable-ref $11 'foo #f)
$12 = bar
scheme@(guile^[$B!]^[(Buser)> (hashtable-set! $11 'baz 'zot)
scheme@(guile^[$B!]^[(Buser)> (hashtable-copy $10 #f)
$13 = #<r6rs:record:r6rs:hashtable>
scheme@(guile^[$B!]^[(Buser)> (hashtable-ref $13 'foo #f)
$14 = bar
scheme@(guile^[$B!]^[(Buser)> (hashtable-set! $13 'baz 'zot)
scheme@(guile^[$B!]^[(Buser)> (hashtable-ref $13 'baz #f)
$15 = #f
scheme@(guile^[$B!]^[(Buser)> (hashtable-mutable? $11)
$16 = #t
scheme@(guile^[$B!]^[(Buser)> (hashtable-mutable? $13)
$17 = #f
and, it appears to that the mutable argument works as expected. $13 is
not mutable, and it does not add an association for 'baz when I tried
it. The only concern I have is that it fails silently, however, since
the r6rs doesn't say anything about the behaviour of hashtable-set! and
hashtable-update! on immutable hashtables, this would be allowed.
--
Ian Price -- shift-reset.com
"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"
next prev parent reply other threads:[~2012-11-26 1:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-25 23:00 Immutable rnrs hashtable Sjoerd van Leent Privé
2012-11-26 1:07 ` Ian Price [this message]
2012-11-26 1:25 ` Ian Price
2012-11-26 9:44 ` Sjoerd van Leent Privé
2012-11-26 10:28 ` Ian Price
2012-11-26 14:18 ` Sjoerd van Leent Privé
2012-11-26 16:34 ` Ludovic Courtès
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=87r4nhb291.fsf@Kagami.home \
--to=ianprice90@googlemail.com \
--cc=guile-devel@gnu.org \
--cc=svanleent@gmail.com \
/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).