From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Dzhus Newsgroups: gmane.emacs.devel Subject: Re: fadr Date: Tue, 23 Jun 2009 01:38:46 +0400 Message-ID: <87tz28eyop.fsf@sphinx.net.ru> References: <87zlc0s3np.fsf@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1245706974 13562 80.91.229.12 (22 Jun 2009 21:42:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 22 Jun 2009 21:42:54 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jun 22 23:42:51 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MIrHv-0001QC-4c for ged-emacs-devel@m.gmane.org; Mon, 22 Jun 2009 23:42:51 +0200 Original-Received: from localhost ([127.0.0.1]:49757 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MIrHu-0003QY-Ee for ged-emacs-devel@m.gmane.org; Mon, 22 Jun 2009 17:42:50 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MIrHp-0003Nw-5a for emacs-devel@gnu.org; Mon, 22 Jun 2009 17:42:45 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MIrHh-0003KW-3C for emacs-devel@gnu.org; Mon, 22 Jun 2009 17:42:44 -0400 Original-Received: from [199.232.76.173] (port=53760 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MIrHg-0003KO-Qk for emacs-devel@gnu.org; Mon, 22 Jun 2009 17:42:36 -0400 Original-Received: from mx20.gnu.org ([199.232.41.8]:27213) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MIrHg-0004L3-Ea for emacs-devel@gnu.org; Mon, 22 Jun 2009 17:42:36 -0400 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MIrHe-0004SE-RF for emacs-devel@gnu.org; Mon, 22 Jun 2009 17:42:35 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1MIrHd-0007JD-BK for emacs-devel@gnu.org; Mon, 22 Jun 2009 21:42:33 +0000 Original-Received: from 95-24-82-94.broadband.corbina.ru ([95.24.82.94]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 22 Jun 2009 21:42:33 +0000 Original-Received: from dima by 95-24-82-94.broadband.corbina.ru with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 22 Jun 2009 21:42:33 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 72 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 95-24-82-94.broadband.corbina.ru User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.95 (gnu/linux) Cancel-Lock: sha1:nCBlo+N7ZkcmMK9rfKbK1D+au+c= X-Detected-Operating-System: by mx20.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:111645 Archived-At: Chong Yidong wrote: > If you need a way to interface easily with nested structures, I > suggest using Common Lisp structures, i.e. the `defstruct' macro which > has been in cl-macs.el for a long time. As long as I understand, with `defstruct` and friends I'll need to declare structure types for each level of my tree-like structure so that I can nest structure slot accessor calls, e.g.: (defstruct threads-response threads current-thread-id) (defstruct thread id target-id state frame) (defstruct frame level addr func args file fullname line) (defstruct arg name value) (setq threads (make-threads-response :threads (list (make-thread :id "1" :target-id "LWP18334" :frame (make-frame :level "0" :addr "0x08048b9a" :func "mult_matrices_mt" :args (list (make-arg :name "m1" :value "0x08048b9a") (make-arg :name "m2" :value "0x0804ba30")) :file "test.c" :fullname "/home/sphinx/projects/gsoc/test.c" :line "142") :state "stopped")) :current-thread-id "1")) (frame-func (thread-frame (first (threads-response-threads threads)))) I'll also need to convert my list-alist trees (I've provided a real example of trees I deal with in my previous mail in this thread) to such structures, though it doesn't seem complex to me. What's good in `defstruct` is that it provides simple type and schema checking, so if my structures get spoiled (which is unlikely, but may happen if GDB's MI changes output format), it will be easier to debug related bugs. I don't think if this is worth investing effort right now, though, probably `binopt.el` code will be sufficient. I believe `defstruct` doesn't impose any performance overhead? Given that I need to handle much less then a hundred trees per one short timeframe. I've grepped through Emacs sources, looking for examples of using `defstruct`, but I haven't found anything resembling my case. I've also found the following notice (mh-loaddefs.el:70): > The `defstruct' in the "cl" library produces compiler warnings, and > generates code that uses functions present in "cl" at run-time. — is this true? The following sentence from cl package info manual is a bit unclear to me: > Also, the `:type' slot option is ignored. Does this mean that `defstruct` procedures are unable to check if slot values provided to structure constructor are of some certain types? So :type slot options used around erc-backend.el:109 are merely harmless annotations for developer? -- Happy Hacking. http://sphinx.net.ru む