guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is gentemp or gensym "safe"?


From: Rob Browning
Subject: Re: Is gentemp or gensym "safe"?
Date: 25 Apr 2001 10:10:16 -0500
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

Martin Grabmueller <address@hidden> writes:

> For me it does take 0 to 2 args.

Perhaps a difference between guile 1.4 and guile cvs then...

> The implementation of gentemp looks like it is avoiding already
> defined symbols, but it obviously doesn't.  What's wrong here?
> 
> guile> (gensym "foo")   
> foo1
> guile> (gensym "foo")
> foo2
> guile> (define foo3 1)
> guile> foo3
> 1
> guile> (gensym "foo") 
> foo3

Wow, that seems kinda broken.  In guile 1.4, it seems to work:

  $ guile
  guile> (gensym "foo")
  foo0
  guile> (gensym "foo")
  foo1
  guile> (define foo2 1) 
  guile> (gensym "foo") 
  foo3
  guile> (version)
  "1.4"
  guile>

Thinking about it, I suppose define-macro isn't really ever safe when
you need temporary variables, unless you scan the incoming form and
make sure to avoid any symbols in there yourself, and even then, you'd
be in trouble if that form contained any macros that might also expand
in ways that would introduce new symbols.

ISTR that common-lisp solved this by having gensym return names from a
reserved namspace that were supposed to globally unique...

So I guess that perhaps trying to use syntax-case might be better,
though I'm less familiar with it :<

-- 
Rob Browning <address@hidden> PGP=E80E0D04F521A094 532B97F5D64E3930



reply via email to

[Prev in Thread] Current Thread [Next in Thread]