From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.bugs Subject: bug#32841: assoc-set fails with dot notation association list Date: Wed, 26 Sep 2018 23:02:17 -0400 Message-ID: <87zhw3d4na.fsf@netris.org> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1538017272 9600 195.159.176.226 (27 Sep 2018 03:01:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 27 Sep 2018 03:01:12 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: 32841@debbugs.gnu.org To: "Hood\, Christopher L." Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Thu Sep 27 05:01:08 2018 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g5MY7-0002Nc-AP for guile-bugs@m.gmane.org; Thu, 27 Sep 2018 05:01:07 +0200 Original-Received: from localhost ([::1]:33529 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5MaD-0002yo-7p for guile-bugs@m.gmane.org; Wed, 26 Sep 2018 23:03:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33690) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Ma1-0002sj-PA for bug-guile@gnu.org; Wed, 26 Sep 2018 23:03:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5MZy-0004s0-Jz for bug-guile@gnu.org; Wed, 26 Sep 2018 23:03:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:51560) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g5MZy-0004rP-G4 for bug-guile@gnu.org; Wed, 26 Sep 2018 23:03:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1g5MZy-0001hO-5W for bug-guile@gnu.org; Wed, 26 Sep 2018 23:03:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mark H Weaver Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Thu, 27 Sep 2018 03:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32841 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 32841-submit@debbugs.gnu.org id=B32841.15380173556495 (code B ref 32841); Thu, 27 Sep 2018 03:03:02 +0000 Original-Received: (at 32841) by debbugs.gnu.org; 27 Sep 2018 03:02:35 +0000 Original-Received: from localhost ([127.0.0.1]:55818 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g5MZX-0001gh-9V for submit@debbugs.gnu.org; Wed, 26 Sep 2018 23:02:35 -0400 Original-Received: from world.peace.net ([64.112.178.59]:39720) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g5MZV-0001gU-2y for 32841@debbugs.gnu.org; Wed, 26 Sep 2018 23:02:33 -0400 Original-Received: from mhw by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1g5MZP-000383-4q; Wed, 26 Sep 2018 23:02:27 -0400 In-Reply-To: (Christopher L. Hood's message of "Tue, 25 Sep 2018 20:33:41 +0000") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.org gmane.lisp.guile.bugs:9172 Archived-At: Hi Christopher, "Hood, Christopher L." writes: > This fails with code pulled straight out of the Guile manual example > (section 6.6.20.6). Indeed, the example code in the manual is bad. Thanks for bringing this to our attention. > (define capitals '(("New York" . "Albany") > ("Oregon" . "Salem") > ("Florida" . "Miami"))) As John correctly pointed out, it's an error to mutate a program literal. It's analogous to trying to modify a string literal in C. 'assoc-set!' mutates the existing list structure in some cases, and so it cannot be used on literals such as the one above. To initialize an alist that will be mutated, you must instead do something like this: (define capitals (list (cons "New York" "Albany") (cons "Oregon" "Salem") (cons "Florida" "Miami"))) > I=E2=80=99ll note that if you define the alist so its initial contents are > defined using a quasiquote and the cons form instead of dot notation, > this error is not reached. Yes, that accomplishes essentially the same thing, although note that quasiquote makes an effort to use program literals for parts of the resulting list structure, e.g.: `(,a ,b c d) expands to: (cons a (cons b '(c d))) which means that the first two cons cells can be mutated, but the last two are part of an immutable program literal. > I=E2=80=99m not sure if the error is valid or not, but in any case, the c= ode > that produces is listed as an valid example in the manual, so that > doesn=E2=80=99t seem right. Indeed, the manual needs to be fixed. Sorry for the confusion, and thanks again for the bug report. Mark