Re: [Scheme-reports] Are generated toplevel definitions secret?
Andy Wingo 07 Nov 2011 11:30 UTC
Hi,
On Tue 24 May 2011 23:10, Andy Wingo <wingo@pobox.com> 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
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports