[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Scheme-reports] Are generated toplevel definitions secret?
On Tue 24 May 2011 23:10, Andy Wingo <wingo@x> writes:
> (define-syntax define-const
> (syntax-rules ()
> ((_ name val)
> (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)
$1 = 10
> (define-const bar 20)
Here I used tab completion to show me the available bindings.
$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:
((_ name val)
(define t val)
((_ v) (set! t v))))))))
(define-variable foo 10)
(define-variable bar 10)
(foo) => 20
I'm not really sure what the right thing is to do here.
Scheme-reports mailing list