all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Semantics of :initform and oset-default
@ 2015-02-09  2:48 Stefan Monnier
  2015-02-09 13:06 ` Eric Ludlam
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2015-02-09  2:48 UTC (permalink / raw)
  To: Eric M. Ludlam; +Cc: emacs-devel

Hi Eric,

I have some questions about the default values of object slots:

- The Texinfo docs say:

     [...]
     The value passed to initform is automatically quoted.  Thus,
          :initform (1 2 3)
     appears as the specified list in the default object.  A symbol that
     [...]

  this seems to say that :initform is really an init*value*.  But then
  in eieio-tests.el we have:

     (defclass inittest nil
       ((staticval :initform 1)
        (symval :initform eieio-test-permuting-value)
        (evalval :initform (symbol-value 'eieio-test-permuting-value))
        (evalnow :initform (symbol-value 'eieio-test-permuting-value)
     	    :allocation :class)
        )
       "Test initforms that eval.")
     
     (ert-deftest eieio-test-21-eval-at-construction-time ()
       ;; initforms that need to be evalled at construction time.
       (setq eieio-test-permuting-value 2)
       (setq eitest-pvinit (inittest))
     
       (should (eq (oref eitest-pvinit staticval) 1))
       (should (eq (oref eitest-pvinit symval) 'eieio-test-permuting-value))
       (should (eq (oref eitest-pvinit evalval) 2))
       (should (eq (oref eitest-pvinit evalnow) 1)))

  which gives a different picture, and I don't really understand it: in
  the `symval' slot the :initform seems to be quoted (as documented),
  but in the other two (`evalval' and `evalnow') the :initforms are
  actually evaluated.

- How is it supposed to interact with oset-default?  Is the value passed
  to `oset-default' interpreted as a plain value (to which the slot
  will always be initialized), or is it interpreted as a "maybe
  value maybe expression to be evaluated", like the :initform?


        Stefan



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

end of thread, other threads:[~2015-02-10  2:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-09  2:48 Semantics of :initform and oset-default Stefan Monnier
2015-02-09 13:06 ` Eric Ludlam
2015-02-09 14:56   ` Stefan Monnier
2015-02-10  0:27     ` Eric Ludlam
2015-02-10  2:47       ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.