From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: User-defined record types, v2 Date: Sat, 18 Mar 2017 19:29:56 +0200 Message-ID: <834lyqxzl7.fsf@gnu.org> References: <86y3w2tt2n.fsf@molnjunk.nocrew.org> <86tw6qtt01.fsf@molnjunk.nocrew.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1489858240 12990 195.159.176.226 (18 Mar 2017 17:30:40 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 18 Mar 2017 17:30:40 +0000 (UTC) Cc: emacs-devel@gnu.org To: Lars Brinkhoff Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Mar 18 18:30:30 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cpIBO-0001yY-Dg for ged-emacs-devel@m.gmane.org; Sat, 18 Mar 2017 18:30:26 +0100 Original-Received: from localhost ([::1]:54184 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cpIBU-0004Q5-E1 for ged-emacs-devel@m.gmane.org; Sat, 18 Mar 2017 13:30:32 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60128) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cpIBN-0004Q0-Sj for emacs-devel@gnu.org; Sat, 18 Mar 2017 13:30:26 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cpIBK-0006wj-Mm for emacs-devel@gnu.org; Sat, 18 Mar 2017 13:30:25 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:35301) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cpIBK-0006wf-JW; Sat, 18 Mar 2017 13:30:22 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:2223 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1cpIBJ-0000ha-C7; Sat, 18 Mar 2017 13:30:22 -0400 In-reply-to: <86tw6qtt01.fsf@molnjunk.nocrew.org> (message from Lars Brinkhoff on Sat, 18 Mar 2017 18:05:50 +0100) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:213137 Archived-At: > From: Lars Brinkhoff > Date: Sat, 18 Mar 2017 18:05:50 +0100 > > Add record objects with user-defined types. Thanks. I hope you will add documentation and some tests at some future point. A few minor comments below. > +static struct Lisp_Vector * > +allocate_record (int count) > +{ > + if (count >= (1 << PSEUDOVECTOR_SIZE_BITS)) > + error ("Record too large"); I think this error should be signaled by the APIs themselves, and it should include the max allowed number and the actual requested number. > +DEFUN ("make-record", Fmake_record, Smake_record, 3, 3, 0, > + doc: /* Create a new record of type TYPE with SLOTS elements, each initialized to INIT. */) This line is too long, I suggest to describe the arguments on separate lines. Also, the doc string should state the maximum allowed value of SLOTS. > +DEFUN ("record", Frecord, Srecord, 1, MANY, 0, > + doc: /* Return a newly created record of type TYPE the rest of the arguments as slots. This line is too long. It also doesn't sound right to me: perhaps "with" is missing? > +Any number of slots, even zero slots, are allowed. Which is a lie, since a number that is too large will cause an error be signaled, right? > + memcpy (p->contents + 1, args + 1, (nargs - 1) * sizeof *args); Should the doc string state that a shallow copy of the arguments is done? > +DEFUN ("copy-record", Fcopy_record, Scopy_record, 1, 1, 0, > + doc: /* Shallow copy of a record. */) I'm not sure this doc string is detailed enough. How about Return a new record that is a shallow copy of the argument RECORD. ? > +INLINE void > +CHECK_RECORD_TYPE (Lisp_Object x) > +{ > + /* CHECK_SYMBOL (x); */ > +} ???