I just use lots of randomness in my generated names.   Collisions will
happen, but only once every trillion years or so.

On Mon, Nov 7, 2011 at 6:30 AM, Andy Wingo <[email protected]> wrote:

> Hi,
>
> On Tue 24 May 2011 23:10, Andy Wingo <[email protected]> writes:
>
> >    (define-syntax define-const
> >      (syntax-rules ()
> >        ((_ name val)
> >         (begin
> >           (define t val)
> >           (define-syntax name (syntax-rules () ((_) t)))))))
> >
> > Guile currently does not make the generated toplevel definition "t" have
> > a fresh name.  It would be nice if it could but it can't be a really
> > random name -- it needs to be predictable.
> >
> > Well why not have the name of "t" be "t" plus some string which depends
> > only on the incoming form -- like its hash value.  (Or the outgoing
> > form; the considerations are different but similar.)
> >
> > That way you do preserve the "compatible recompilation" aspect, trading
> > off true secrecy, but hey.  Oh well.
>
> FWIW, I have implemented this in Guile's master branch.
>
>  > (define-const foo 10)
>  > t-798f2ffcb9d7f9
>  $1 = 10
>  > (define-const bar 20)
>  > t-
>  t-1a0faae6e8559b31  t-798f2ffcb9d7f9
>
> Here I used tab completion to show me the available bindings.
>
>  > t-1a0faae6e8559b31
>  $2 = 20
>
> The appended uniquifiers are derived from the hash of the stripped
> definition form, i.e. `(define t 10)'.  This means that there are still
> some situations in which two bindings will collide -- as in:
>
>   (define-syntax define-variable
>      (syntax-rules ()
>       ((_ name val)
>         (begin
>           (define t val)
>          (define-syntax name
>            (syntax-rules ()
>              ((_) t)
>               ((_ v) (set! t v))))))))
>
>   (define-variable foo 10)
>   (define-variable bar 10)
>   (bar 20)
>   (foo) => 20
>
> I'm not really sure what the right thing is to do here.
>
> Andy
> --
> http://wingolog.org/
>
> _______________________________________________
> Scheme-reports mailing list
> [email protected]
> http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports
>
_______________________________________________
Scheme-reports mailing list
[email protected]
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports

Reply via email to