* bug#22449: (rnrs hashtables): Mutation of immutable hashtable ignored
@ 2016-01-23 22:57 "Taylan Ulrich Bayırlı/Kammer"
0 siblings, 0 replies; only message in thread
From: "Taylan Ulrich Bayırlı/Kammer" @ 2016-01-23 22:57 UTC (permalink / raw)
To: 22449
I couldn't find explicit wording in R6RS on what should happen, but I
would generally expect an attempt to mutate an immutable object to
raise an error. In Guile,
(hashtable-set! (hashtable-copy (make-eq-hashtable)) 'foo 'bar)
is silently ignored.
Attached is a simple patch that raises an assertion violation when the
hashtable is immutable.
Taylan
===File
/home/taylan/src/guile/guile-stable-2.0/0001-Hashtable-set-errors-on-immutable-hashtable.patch===
From dd6c4bbbe85a57fcbb08bdc7847075bddc1f0d87 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Taylan=20Ulrich=20Bay=C4=B1rl=C4=B1/Kammer?=
<taylanbayirli@gmail.com>
Date: Sat, 23 Jan 2016 22:35:24 +0100
Subject: [PATCH] Hashtable-set! errors on immutable hashtable.
* module/rnrs/hashtables.scm (hashtable-set!): Raise an assertion
violation error when the hashtable is immutable.
---
module/rnrs/hashtables.scm | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/module/rnrs/hashtables.scm b/module/rnrs/hashtables.scm
index 98d2d76..5773eb1 100644
--- a/module/rnrs/hashtables.scm
+++ b/module/rnrs/hashtables.scm
@@ -122,8 +122,9 @@
(define (hashtable-set! hashtable key obj)
(if (r6rs:hashtable-mutable? hashtable)
- (hash-table-set! (r6rs:hashtable-wrapped-table hashtable) key obj))
- *unspecified*)
+ (hash-table-set! (r6rs:hashtable-wrapped-table hashtable) key obj)
+ (assertion-violation
+ 'hashtable-set! "Hashtable is immutable." hashtable)))
(define (hashtable-delete! hashtable key)
(if (r6rs:hashtable-mutable? hashtable)
--
2.6.3
============================================================
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2016-01-23 22:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-23 22:57 bug#22449: (rnrs hashtables): Mutation of immutable hashtable ignored "Taylan Ulrich Bayırlı/Kammer"
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).