all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Dzhus <dima@sphinx.net.ru>
To: emacs-devel@gnu.org
Subject: Re: fadr
Date: Tue, 23 Jun 2009 01:38:46 +0400	[thread overview]
Message-ID: <87tz28eyop.fsf@sphinx.net.ru> (raw)
In-Reply-To: 87zlc0s3np.fsf@stupidchicken.com

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

  parent reply	other threads:[~2009-06-22 21:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-22 15:12 fadr Chong Yidong
2009-06-22 16:14 ` fadr Thien-Thi Nguyen
2009-06-22 19:56   ` fadr Dmitry Dzhus
2009-06-23  9:14     ` fadr Thien-Thi Nguyen
2009-06-22 16:27 ` fadr Dmitry Dzhus
2009-06-22 16:39   ` fadr Chong Yidong
2009-06-22 18:24   ` fadr Glenn Morris
2009-06-22 21:57     ` fadr Dmitry Dzhus
2009-06-24 21:33       ` fadr Stefan Monnier
2009-06-23  5:54     ` fadr Nick Roberts
2009-06-22 21:38 ` Dmitry Dzhus [this message]
2009-06-23  5:47 ` fadr Nick Roberts

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tz28eyop.fsf@sphinx.net.ru \
    --to=dima@sphinx.net.ru \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.