From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stephen Leake Newsgroups: gmane.emacs.devel Subject: force initialization of a datatype? Date: Wed, 04 Nov 2015 10:28:39 -0600 Message-ID: <86lhadybig.fsf@stephe-leake.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1446655072 30044 80.91.229.3 (4 Nov 2015 16:37:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 4 Nov 2015 16:37:52 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Nov 04 17:37:42 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Zu148-0000C0-O3 for ged-emacs-devel@m.gmane.org; Wed, 04 Nov 2015 17:37:40 +0100 Original-Received: from localhost ([::1]:55820 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zu148-0002NQ-69 for ged-emacs-devel@m.gmane.org; Wed, 04 Nov 2015 11:37:40 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42651) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zu0vl-0004XJ-QY for emacs-devel@gnu.org; Wed, 04 Nov 2015 11:29:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zu0vi-0004iL-Dr for emacs-devel@gnu.org; Wed, 04 Nov 2015 11:29:01 -0500 Original-Received: from gproxy1-pub.mail.unifiedlayer.com ([69.89.25.95]:46181) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1Zu0vi-0004g2-6E for emacs-devel@gnu.org; Wed, 04 Nov 2015 11:28:58 -0500 Original-Received: (qmail 4190 invoked by uid 0); 4 Nov 2015 16:28:56 -0000 Original-Received: from unknown (HELO CMOut01) (10.0.90.82) by gproxy1.mail.unifiedlayer.com with SMTP; 4 Nov 2015 16:28:56 -0000 Original-Received: from host114.hostmonster.com ([74.220.207.114]) by CMOut01 with id dUUo1r01f2UdiVW01UUrdQ; Wed, 04 Nov 2015 09:28:54 -0700 X-Authority-Analysis: v=2.1 cv=VOBOwb/X c=1 sm=1 tr=0 a=CQdxDb2CKd3SRg4I0/XZPQ==:117 a=CQdxDb2CKd3SRg4I0/XZPQ==:17 a=DsvgjBjRAAAA:8 a=f5113yIGAAAA:8 a=9i_RQKNPAAAA:8 a=hEr_IkYJT6EA:10 a=x_XPkuGwIRMA:10 a=qtqOOiqGOCEA:10 a=38Vfoo3qRFCI2yBQ2SoA:9 Original-Received: from [76.218.37.33] (port=57671 helo=TAKVER2) by host114.hostmonster.com with esmtpa (Exim 4.84) (envelope-from ) id 1Zu0vZ-0002RZ-LB for emacs-devel@gnu.org; Wed, 04 Nov 2015 09:28:49 -0700 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (windows-nt) X-Identified-User: {2442:host114.hostmonster.com:stephele:stephe-leake.org} {sentby:smtp auth 76.218.37.33 authed with stephen_leake@stephe-leake.org} X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 69.89.25.95 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:193212 Archived-At: 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)) ) (defun make-path-iterator () (let ((result (vector 'cl-struct-path-iterator ))) )) 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