From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] trunk r116995: cl-lib defstruct introspection Date: Mon, 21 Apr 2014 23:28:09 -0400 Message-ID: References: <53555822.3080007@dancol.org> <53559B0D.3070505@dancol.org> <5355CECF.2050803@dancol.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1398137324 21708 80.91.229.3 (22 Apr 2014 03:28:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 22 Apr 2014 03:28:44 +0000 (UTC) Cc: emacs-devel@gnu.org To: Daniel Colascione Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Apr 22 05:28:34 2014 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 1WcRNq-00073i-1J for ged-emacs-devel@m.gmane.org; Tue, 22 Apr 2014 05:28:34 +0200 Original-Received: from localhost ([::1]:52546 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcRNp-0007y8-JB for ged-emacs-devel@m.gmane.org; Mon, 21 Apr 2014 23:28:33 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49530) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcRNf-0007xx-3R for emacs-devel@gnu.org; Mon, 21 Apr 2014 23:28:30 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WcRNX-00089Z-JY for emacs-devel@gnu.org; Mon, 21 Apr 2014 23:28:23 -0400 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:32906) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcRNX-00089U-EJ for emacs-devel@gnu.org; Mon, 21 Apr 2014 23:28:15 -0400 Original-Received: from pastel.home (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id s3M3S9Y0005721; Mon, 21 Apr 2014 23:28:10 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id B3937600CA; Mon, 21 Apr 2014 23:28:09 -0400 (EDT) In-Reply-To: <5355CECF.2050803@dancol.org> (Daniel Colascione's message of "Mon, 21 Apr 2014 19:07:11 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4919=0 X-NAI-Spam-Version: 2.3.0.9378 : core <4919> : inlines <752> : streams <1164255> : uri <1736976> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 132.204.246.22 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:171562 Archived-At: > 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.