emacs-devel
[Top][All Lists]
Advanced

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

Re: lexbind: how to replace lexical-let approach to hide secrets


From: Stefan Monnier
Subject: Re: lexbind: how to replace lexical-let approach to hide secrets
Date: Wed, 30 Mar 2011 17:12:37 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

> Slightly related: auth-source.el uses `lexical-let' to define lambda
> accessors for secrets (so printing them, for instance, won't show a
> password).  Will the secrets still be hidden in the lexbind branch?

Using lexbind, yes.  Using `let', no.

> And
> is there a smarter way to do it?

> Sample code:

> (let ((data "my secret"))
>   (lexical-let ((data data)) (lambda () data)))

When lexical-binding is set:

 (let ((data "my secret"))
   (lambda () data))

returns something like (closure ((data . "my secret") t) () data).
If you wan to hide the value, then use:

  (let ((data (let ((sym (make-symbol "foo")))
                (set sym "secret")
                sym)))
    (lambda () (symbol-value data)))

which is similar to the what lexical-let ends up doing.


        Stefan



reply via email to

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