From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ian Price Newsgroups: gmane.lisp.guile.devel Subject: Re: Immutable rnrs hashtable Date: Mon, 26 Nov 2012 01:07:38 +0000 Message-ID: <87r4nhb291.fsf@Kagami.home> References: <50B2A31B.1070903@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-2022-jp-2 X-Trace: ger.gmane.org 1353892073 26133 80.91.229.3 (26 Nov 2012 01:07:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 26 Nov 2012 01:07:53 +0000 (UTC) Cc: guile-devel@gnu.org To: Sjoerd van Leent =?iso-8859-1?Q?Priv=E9?= Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Nov 26 02:08:04 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TcnB5-0004ui-15 for guile-devel@m.gmane.org; Mon, 26 Nov 2012 02:08:03 +0100 Original-Received: from localhost ([::1]:34567 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TcnAu-00067D-0x for guile-devel@m.gmane.org; Sun, 25 Nov 2012 20:07:52 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:56611) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TcnAq-00066R-V0 for guile-devel@gnu.org; Sun, 25 Nov 2012 20:07:49 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TcnAp-00052B-Mz for guile-devel@gnu.org; Sun, 25 Nov 2012 20:07:48 -0500 Original-Received: from mail-we0-f169.google.com ([74.125.82.169]:41061) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TcnAp-000526-Ff for guile-devel@gnu.org; Sun, 25 Nov 2012 20:07:47 -0500 Original-Received: by mail-we0-f169.google.com with SMTP id t49so2605996wey.0 for ; Sun, 25 Nov 2012 17:07:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=zYSlRO2MaSqlTyxuXrAhBjAOT0dW2+KSJYvO+fjrvzs=; b=aYwwkIbkI9GTimW0mPn1sgnp9qWUqaYozLdjh0BD9VO2g9IiBVqiqWTHIKxp2Z+MBl dA/d4w7YpajGuva8ft2MAuQX7XMt9HrDu8ehZkWYoldE+6ovZHCPeFo/mf/cATHzs3Qx pA5O8Fci7XLhdMti0+VyHPThevWW6XsAvLZ7H22cUuWPw0h7njtg6LR634JDo1DE3gbI kvnNOyF5xPsr23YaCri467e1Q2hq2QcFNnOYc3c0/W9KeB5OGvUpnccHlPkeOliRs/Ut rcfiVvT7e+3p4UxN7iPMsCFshSYYK+Li7blbZVtWa++5ZcruUbnMXbez7BVVhoc381HI xWgA== Original-Received: by 10.216.227.132 with SMTP id d4mr3783684weq.33.1353892066753; Sun, 25 Nov 2012 17:07:46 -0800 (PST) Original-Received: from Kagami.home (host86-182-157-241.range86-182.btcentralplus.com. [86.182.157.241]) by mx.google.com with ESMTPS id bd7sm6962057wib.8.2012.11.25.17.07.42 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 25 Nov 2012 17:07:45 -0800 (PST) In-Reply-To: <50B2A31B.1070903@gmail.com> ("Sjoerd van Leent =?iso-8859-1?Q?Priv=E9=22's?= message of "Mon, 26 Nov 2012 00:00:43 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 74.125.82.169 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:15253 Archived-At: Sjoerd van Leent Priv$(D+1(B 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 = # scheme@(guile$B!](Buser)> (hashtable-set! $10 'foo 'bar) scheme@(guile$B!](Buser)> (hashtable-copy $10 #t) $11 = # 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 = # 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"