From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Yuan Fu <casouri@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Edit a cl-struct by copy, or, slot-value for cl-structs
Date: Sun, 31 Oct 2021 14:52:28 -0400 [thread overview]
Message-ID: <jwvpmrljajy.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <C2FBF0B1-E443-46CA-8626-2A5B468343AF@gmail.com> (Yuan Fu's message of "Fri, 29 Oct 2021 14:46:45 -0700")
>>> (mapcar #'cl--slot-descriptor-name
>>> (cl--struct-class-slots (get (type-of obj) 'cl--class)))
>>>
>>> But I can’t get any further as I can’t find any generic getter and
>>> setter for cl-struct’s. Something like slot-value. So close!
FWIW, I just pushed to `master` a patch which makes `slot-value` work to
read slots from structs. It doesn't help you, tho, because it still
doesn't let you set them, and in your case it really shouldn't since
they are defined as read-only.
>> and then use (my-foo-with foo :c 42) and (my-foo-with-a foo 153 "42”)
> That’s cool. But my lazy fingers like better to write a single function and
> use it for everything ;-)
But that tends to come at a performance cost.
Stefan
next prev parent reply other threads:[~2021-10-31 18:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-29 18:27 Edit a cl-struct by copy, or, slot-value for cl-structs Yuan Fu
2021-10-29 18:43 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-29 21:44 ` Yuan Fu
2021-10-29 19:15 ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-10-29 21:46 ` Yuan Fu
2021-10-31 18:52 ` Stefan Monnier [this message]
2021-10-29 21:37 ` Michael Heerdegen
2021-10-29 22:02 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-29 23:14 ` Michael Heerdegen
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=jwvpmrljajy.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=casouri@gmail.com \
--cc=help-gnu-emacs@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.
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).