all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* force initialization of a datatype?
@ 2015-11-04 16:28 Stephen Leake
  2015-11-04 19:17 ` Dmitry Gutov
  0 siblings, 1 reply; 8+ messages in thread
From: Stephen Leake @ 2015-11-04 16:28 UTC (permalink / raw)
  To: emacs-devel

I'm working on a type that should check the user provided
inititalization values, and I'm wondering if I can do that with
cl-defstruct, or if I should use eieio defclass instead.

I'd like to ensure that the only available constructors do the
checking.

Here's what I have come up with for cl-defstruct:

(cl-defstruct (path-iterator
	       (:constructor nil)
	       (:copier nil))
  <slots>
  )

(defun make-path-iterator (<user args>)
  (let ((result (vector 'cl-struct-path-iterator <slot values>)))
    <code to check the user args and set the slots in `result'>
    ))

This code compiles and runs correctly, but I'm wondering if it is
acceptable style. Is there a better way to accomplish this for
cl-defstruct?


eieio defclass provides ":initform", which I'm guessing can specify a
function to run at object construction time, but I can't find any
definitive statement to that effect, neither in the Emacs info doc nor
via DuckDuckGo search. The lack of good documentation scares me away
from eieio in general.

-- 
-- Stephe



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

end of thread, other threads:[~2015-11-07 20:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-04 16:28 force initialization of a datatype? Stephen Leake
2015-11-04 19:17 ` Dmitry Gutov
2015-11-06 11:56   ` Stephen Leake
2015-11-06 12:16     ` Dmitry Gutov
2015-11-07  7:05       ` Stephen Leake
2015-11-07 16:27         ` Dmitry Gutov
2015-11-07 18:30           ` Stephen Leake
2015-11-07 20:21             ` Dmitry Gutov

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.