unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* lexical binding changes symbol standard-value property
@ 2016-06-29 13:51 Paul Rankin
  2016-06-29 15:10 ` Drew Adams
  2016-06-30  7:43 ` Stefan Monnier
  0 siblings, 2 replies; 3+ messages in thread
From: Paul Rankin @ 2016-06-29 13:51 UTC (permalink / raw)
  To: help-gnu-emacs

Something strange is going on with lexical-binding and defcustom...

(defcustom dummy-var t
  "This is a test var.")
;; => dummy-var

(car (get 'dummy-var 'standard-value))
;; => t

(setq lexical-binding t)
;; => t

(defcustom dummy-var t
  "This is a test var.")
;; = dummy-var

(car (get 'dummy-var 'standard-value))
;; => (funcall (function (closure (t) nil t)))

Why is the standard-value property of dummy-var changing? I kinda need it to be consistent...

I can resolve with:
(eval (car (get 'dummy-var 'standard-value)
;; => t
...but not sure about using (eval ...)

Ideas?

-- 
Paul W. Rankin
www.paulwrankin.com



^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: lexical binding changes symbol standard-value property
  2016-06-29 13:51 lexical binding changes symbol standard-value property Paul Rankin
@ 2016-06-29 15:10 ` Drew Adams
  2016-06-30  7:43 ` Stefan Monnier
  1 sibling, 0 replies; 3+ messages in thread
From: Drew Adams @ 2016-06-29 15:10 UTC (permalink / raw)
  To: Paul Rankin, help-gnu-emacs

> (car (get 'dummy-var 'standard-value))
> ;; => (funcall (function (closure (t) nil t)))
> 
> Why is the standard-value property of dummy-var changing? I kinda need it to
> be consistent...
> 
> I can resolve with:
> (eval (car (get 'dummy-var 'standard-value)
> ;; => t
> ...but not sure about using (eval ...)
> 
> Ideas?

Kinda looks like a bug, to me.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: lexical binding changes symbol standard-value property
  2016-06-29 13:51 lexical binding changes symbol standard-value property Paul Rankin
  2016-06-29 15:10 ` Drew Adams
@ 2016-06-30  7:43 ` Stefan Monnier
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2016-06-30  7:43 UTC (permalink / raw)
  To: help-gnu-emacs

> (car (get 'dummy-var 'standard-value))
> ;; => t

(car (get 'dummy-var 'standard-value)) is defined to contain an
*expression* rather than a *value*.

> I can resolve with:
> (eval (car (get 'dummy-var 'standard-value)
> ;; => t
> ...but not sure about using (eval ...)

Using `eval' is (and always has been) the only correct way to get the
"standard-value".

E.g.

    (defcustom sm-test (+ 1 2) "hello")
    (car (get 'sm-test 'standard-value))

returns (+ 1 2) rather than 3 (well, with lexical-binding it returns
yet something else, but that is also an expression which evaluates to
3).


        Stefan




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-06-30  7:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-29 13:51 lexical binding changes symbol standard-value property Paul Rankin
2016-06-29 15:10 ` Drew Adams
2016-06-30  7:43 ` Stefan Monnier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).