From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: rain1@openmailbox.org Newsgroups: gmane.lisp.guile.bugs Subject: bug#20087: gensym Date: Tue, 22 Mar 2016 11:21:05 +0000 Message-ID: References: <87a8zjxxpl.fsf@gnu.org> <87twjzytit.fsf@netris.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1458646223 17294 80.91.229.3 (22 Mar 2016 11:30:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 22 Mar 2016 11:30:23 +0000 (UTC) To: 20087@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Tue Mar 22 12:30:14 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 1aiKVp-00062M-Hz for guile-bugs@m.gmane.org; Tue, 22 Mar 2016 12:30:13 +0100 Original-Received: from localhost ([::1]:35419 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aiKVo-0005jm-0s for guile-bugs@m.gmane.org; Tue, 22 Mar 2016 07:30:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39450) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aiKVh-0005i2-VO for bug-guile@gnu.org; Tue, 22 Mar 2016 07:30:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aiKVe-0000uB-Np for bug-guile@gnu.org; Tue, 22 Mar 2016 07:30:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:60662) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aiKVe-0000to-Hv for bug-guile@gnu.org; Tue, 22 Mar 2016 07:30:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1aiKVe-0006Dj-8B for bug-guile@gnu.org; Tue, 22 Mar 2016 07:30:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: rain1@openmailbox.org Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Tue, 22 Mar 2016 11:30:02 +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.145864614523821 (code B ref 20087); Tue, 22 Mar 2016 11:30:02 +0000 Original-Received: (at 20087) by debbugs.gnu.org; 22 Mar 2016 11:29:05 +0000 Original-Received: from localhost ([127.0.0.1]:57789 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aiKUj-0006C9-7b for submit@debbugs.gnu.org; Tue, 22 Mar 2016 07:29:05 -0400 Original-Received: from mail2.openmailbox.org ([62.4.1.33]:59256) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aiKNA-00061G-1Z for 20087@debbugs.gnu.org; Tue, 22 Mar 2016 07:21:16 -0400 Original-Received: by mail2.openmailbox.org (Postfix, from userid 1004) id 2D7D82AC7E67; Tue, 22 Mar 2016 12:21:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=openmailbox.org; s=openmailbox; t=1458645674; bh=McV3Pt2cVcKV774UMIQjNTT1H+QpBCdB6T+V2EmNAyI=; h=Date:From:To:Subject:In-Reply-To:References:From; b=o4jnPPSfvZVwkdO0xWTAxgJxz1DwqrkGvtBqtx/KG/CWyWcrvSOc+XK7xqo1WW3n7 BLiv0ojvtqjOSSJaPsLzvmdR9ut3Xb6BdvtzhoF8KnG7JLG5N0a0RjdTunhya1wIhP v9lIkn9R0CGaCsk28zmJLSzA3KLkIejMTfEW3cRw= Original-Received: from www.openmailbox.org (openmailbox-b1 [10.91.69.218]) by mail2.openmailbox.org (Postfix) with ESMTP id CB2B72ACD4F5 for <20087@debbugs.gnu.org>; Tue, 22 Mar 2016 12:21:05 +0100 (CET) In-Reply-To: <87twjzytit.fsf@netris.org> X-Sender: rain1@openmailbox.org User-Agent: Roundcube Webmail/1.0.6 X-Mailman-Approved-At: Tue, 22 Mar 2016 07:29:04 -0400 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:7994 Archived-At: On 2016-03-22 05:24, Mark H Weaver wrote: > ludo@gnu.org (Ludovic Courtès) writes: >> ‘gensym’ returns interned symbols, but the algorithm to determine the >> new symbol is simplistic and predictable. >> >> Thus, one can arrange to produce a symbol before ‘gensym’ does, >> leading >> ‘gensym’ to return a symbol that’s not fresh (in terms of ‘eq?’), as >> is >> the case with the second call to ‘gensym’ 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. Thanks for looking over the patch I sent! One expects of gensym to create a fresh symbol, something not EQ? to any symbol that already exists. It is an important property to be able to rely on and this patch achieves that. About symbols interned after, would that refer to something like this: ------------------------ scheme@(guile-user)> (define a (gensym "x")) scheme@(guile-user)> a $1 = x280 scheme@(guile-user)> (eq? a (string->symbol "x280")) $2 = #t ------------------------ In most lisps gensym creates an uninterned symbol. I think that would stop the previous giving #t. I could write a patch for this if wanted.