From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.bugs Subject: bug#20087: gensym Date: Tue, 22 Mar 2016 01:24:26 -0400 Message-ID: <87twjzytit.fsf@netris.org> References: <87a8zjxxpl.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1458624326 9600 80.91.229.3 (22 Mar 2016 05:25:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 22 Mar 2016 05:25:26 +0000 (UTC) Cc: 20087@debbugs.gnu.org, Ludovic =?UTF-8?Q?Court=C3=A8s?= To: rain1@openmailbox.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Tue Mar 22 06:25:10 2016 Return-path: Envelope-to: guile-bugs@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 1aiEoY-0006uq-2X for guile-bugs@m.gmane.org; Tue, 22 Mar 2016 06:25:10 +0100 Original-Received: from localhost ([::1]:33821 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aiEoX-0004uQ-6U for guile-bugs@m.gmane.org; Tue, 22 Mar 2016 01:25:09 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55238) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aiEoR-0004sB-6u for bug-guile@gnu.org; Tue, 22 Mar 2016 01:25:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aiEoQ-0000zx-43 for bug-guile@gnu.org; Tue, 22 Mar 2016 01:25:03 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:60495) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aiEoQ-0000zt-0t for bug-guile@gnu.org; Tue, 22 Mar 2016 01:25:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1aiEoP-0004BG-Qe for bug-guile@gnu.org; Tue, 22 Mar 2016 01:25:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mark H Weaver Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Tue, 22 Mar 2016 05:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20087 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 20087-submit@debbugs.gnu.org id=B20087.145862428716046 (code B ref 20087); Tue, 22 Mar 2016 05:25:01 +0000 Original-Received: (at 20087) by debbugs.gnu.org; 22 Mar 2016 05:24:47 +0000 Original-Received: from localhost ([127.0.0.1]:57622 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aiEoA-0004Ak-SA for submit@debbugs.gnu.org; Tue, 22 Mar 2016 01:24:47 -0400 Original-Received: from world.peace.net ([50.252.239.5]:53874 ident=hope2) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aiEo8-0004Ab-O1 for 20087@debbugs.gnu.org; Tue, 22 Mar 2016 01:24:45 -0400 Original-Received: from [10.1.10.68] (helo=yeeloong) by world.peace.net with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1aiEnx-0006Mu-Uy; Tue, 22 Mar 2016 01:24:34 -0400 In-Reply-To: (rain1@openmailbox.org's message of "Fri, 18 Mar 2016 17:03:27 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.92 (gnu/linux) 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-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:7992 Archived-At: ludo@gnu.org (Ludovic Court=C3=A8s) writes: > =E2=80=98gensym=E2=80=99 returns interned symbols, but the algorithm to d= etermine the > new symbol is simplistic and predictable. >=20 > Thus, one can arrange to produce a symbol before =E2=80=98gensym=E2=80=99= does, leading > =E2=80=98gensym=E2=80=99 to return a symbol that=E2=80=99s not fresh (in = terms of =E2=80=98eq?=E2=80=99), as is > the case with the second call to =E2=80=98gensym=E2=80=99 here: rain1@openmailbox.org writes: > I agree, this goes against the main assumption people have about > gensym. I was able to reproduce the bug. > > Here's a patch to libguile/symbol.c which fixes this behavior by > incrementing the gensym counter in a loop until it creates a fresh > symbol. I've considered this idea in the past, but it only avoids collisions with symbols that have been interned before the gensym. It does not avoid collisions with symbols interned *after* the gensym. Obviously, there's no way to avoid such collisions. Therefore, we must unfortunately live with the possibility of collisions. Furthermore, if we add a requirement for deterministic behavior (which I think we must), then we must live with the fact that intentional collisions can be trivially achieved. With this in mind, I'm not sure it makes sense to add code that attempts, but fails, to eliminate the possibility of collisions. If we cannot eliminate the possibility of collisions, and we cannot avoid intentional collisions, what can we do? I think the best we can hope for is to significantly reduce the probability of _unintentional_ collisions, perhaps by starting the gensym counter at a large number. The other thing we can do is to clearly document these inherent problems with gensym, so that they will not be misused for jobs for which they are not appropriate. What do you think? Mark