From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: force initialization of a datatype? Date: Wed, 4 Nov 2015 21:17:17 +0200 Message-ID: <563A59BD.6010909@yandex.ru> References: <86lhadybig.fsf@stephe-leake.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1446664668 4736 80.91.229.3 (4 Nov 2015 19:17:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 4 Nov 2015 19:17:48 +0000 (UTC) To: Stephen Leake , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Nov 04 20:17: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 1Zu3Yx-0005yS-SI for ged-emacs-devel@m.gmane.org; Wed, 04 Nov 2015 20:17:40 +0100 Original-Received: from localhost ([::1]:56718 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zu3Yx-0000Cf-FM for ged-emacs-devel@m.gmane.org; Wed, 04 Nov 2015 14:17:39 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42021) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zu3Yj-0000CD-S1 for emacs-devel@gnu.org; Wed, 04 Nov 2015 14:17:26 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zu3Yf-0004N2-Hd for emacs-devel@gnu.org; Wed, 04 Nov 2015 14:17:25 -0500 Original-Received: from mail-wi0-x22a.google.com ([2a00:1450:400c:c05::22a]:35782) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zu3Yf-0004My-BQ for emacs-devel@gnu.org; Wed, 04 Nov 2015 14:17:21 -0500 Original-Received: by wicll6 with SMTP id ll6so96393006wic.0 for ; Wed, 04 Nov 2015 11:17:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=9os11AjF9ZQWdiTy6mAC6b+SjqDHXXqC1oH3FOsTi1o=; b=qFzKFWvvSucLYgSUbAQvpNR7tV5D5fl3q7kaS/u5+utedAdummZym+G+zl7FW3K/9j 7NfDNSYktxGKbi0rP8m8Smqqf6/knEfZhUKwbIWZ9NZr5JtchF0IKHPyweGIr/bkPPdU dKZPkw++Yh1svY1WkJ8wlecGFyEoTLLWmwj12DuY9zldzvs+au4yyXkm16EdeM5golCc 4ssfMfoZygrFTD487p3DWTArV3GjVL46oOMdfmBk44Mmv8qwacYIca38+qfLEFS5v/n8 ACyZEem0PG8hsqzd84RulAL3yZy/3VuJCWtu2zDp89S1M4Z4tqQJFhmd4TPIpXhhC4Y9 pXyQ== X-Received: by 10.194.82.202 with SMTP id k10mr4368537wjy.85.1446664640440; Wed, 04 Nov 2015 11:17:20 -0800 (PST) Original-Received: from [192.168.1.2] ([185.105.175.24]) by smtp.googlemail.com with ESMTPSA id jq10sm3041461wjc.37.2015.11.04.11.17.18 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Nov 2015 11:17:19 -0800 (PST) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Thunderbird/42.0 In-Reply-To: <86lhadybig.fsf@stephe-leake.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::22a 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:193228 Archived-At: On 11/04/2015 06:28 PM, Stephen Leake wrote: > (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? Using `vector' looks wrong. I'm not too familiar with constructor syntax, but you can process each slot value before an instance gets constructed. See the example with &aux in http://www.gnu.org/software/emacs/manual/html_node/cl/Structures.html, or package-desc-from-define in package.el. I'm not sure whether you can use a keyword argument with the same name as the slot, and convert the passed in value. That's something to try. > 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. If we're talking about xref, I think it would be generally good to migrate away from eieio in the core definitions. defstruct is lighter, and seems functional enough for our purposes.