unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Daniel Colascione <dancol@dancol.org>
Cc: emacs-devel@gnu.org
Subject: Re: [Emacs-diffs] trunk r116995: cl-lib defstruct introspection
Date: Mon, 21 Apr 2014 23:28:09 -0400	[thread overview]
Message-ID: <jwveh0qm4j2.fsf-monnier+emacsdiffs@gnu.org> (raw)
In-Reply-To: <5355CECF.2050803@dancol.org> (Daniel Colascione's message of "Mon, 21 Apr 2014 19:07:11 -0700")

> Something like this. (This is the private code I was talking about, so
> it doesn't use the sames in the checked-in patch.)

> (defmacro* jez-with-slots (spec-list (type inst) &body body)
>   "Like `with-slots', but for structs."
>   (if (symbolp inst)
>       `(symbol-macrolet
>            ,(loop for spec in spec-list
>                   collect `(,spec (jez-slot-value ',type ,inst ',spec)))
>          ,@body)
>     (let ((inst-symbol (gensym "with-struct-slots")))
>       `(let ((,inst-symbol ,inst))
>          (jez-with-slots
>              ,spec-list ,inst-symbol ,@body)))))

Ah, I see now, thanks, yes that makes sense.


        Stefan


PS: Of course, I wouldn't implement it that way ;-)
I'd start by testing `inst' against `type' and then use straight (aref
...)  or (nth ...) for the accessors.
But indeed, you'd want to circumvent the usual accessors.



  reply	other threads:[~2014-04-22  3:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1Wbhqn-0001CJ-4X@vcs.savannah.gnu.org>
2014-04-20 12:49 ` [Emacs-diffs] trunk r116995: cl-lib defstruct introspection Stefan Monnier
2014-04-23 12:56   ` Stefan Monnier
2014-04-21 15:38 ` Stefan Monnier
2014-04-21 17:40   ` Daniel Colascione
2014-04-21 22:03     ` Stefan Monnier
2014-04-21 22:26       ` Daniel Colascione
2014-04-22  2:03         ` Stefan Monnier
2014-04-22  2:07           ` Daniel Colascione
2014-04-22  3:28             ` Stefan Monnier [this message]
2014-04-23  3:18       ` Declaim and proclaim (Was: Re: [Emacs-diffs] trunk r116995: cl-lib defstruct introspection) Daniel Colascione
2014-04-23 13:14         ` Declaim and proclaim Stefan Monnier

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=jwveh0qm4j2.fsf-monnier+emacsdiffs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=dancol@dancol.org \
    --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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).