unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: rain1@openmailbox.org
Cc: 20087@debbugs.gnu.org, "Ludovic Courtès" <ludo@gnu.org>
Subject: bug#20087: gensym
Date: Tue, 22 Mar 2016 01:24:26 -0400	[thread overview]
Message-ID: <87twjzytit.fsf@netris.org> (raw)
In-Reply-To: <df0d878daef767b6802adbec4b5ed780@openmailbox.org> (rain1@openmailbox.org's message of "Fri, 18 Mar 2016 17:03:27 +0000")

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.

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





  reply	other threads:[~2016-03-22  5:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-11 17:15 bug#20087: 'gensym' is not guaranteed to return a fresh symbol Ludovic Courtès
2016-03-18 17:03 ` bug#20087: gensym rain1
2016-03-22  5:24   ` Mark H Weaver [this message]
2016-03-22  7:58     ` Ludovic Courtès
2016-03-23 17:55       ` Mark H Weaver
2016-03-24  8:45         ` Ludovic Courtès
2016-06-23 13:48           ` Andy Wingo
2016-06-23 14:13             ` Ludovic Courtès
2016-06-23 16:05               ` Andy Wingo
2016-03-22 11:21     ` rain1
2016-03-22 18:06       ` Mark H Weaver

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87twjzytit.fsf@netris.org \
    --to=mhw@netris.org \
    --cc=20087@debbugs.gnu.org \
    --cc=ludo@gnu.org \
    --cc=rain1@openmailbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).