[Top][All Lists]

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

force initialization of a datatype?

From: Stephen Leake
Subject: force initialization of a datatype?
Date: Wed, 04 Nov 2015 10:28:39 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (windows-nt)

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

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

(cl-defstruct (path-iterator
               (:constructor nil)
               (:copier nil))

(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

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

reply via email to

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