From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.help Subject: Re: Edit a cl-struct by copy, or, slot-value for cl-structs Date: Fri, 29 Oct 2021 14:46:45 -0700 Message-ID: References: <06C2AE7C-C3E9-4E34-9394-B431173639E9@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 15.0 \(3693.20.0.1.32\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32220"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs@gnu.org To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Oct 29 23:56:22 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mgZrI-0008AX-Pe for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 29 Oct 2021 23:56:20 +0200 Original-Received: from localhost ([::1]:35134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mgZrH-0006HF-Ph for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 29 Oct 2021 17:56:19 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60620) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mgZi6-0007z2-Gg for help-gnu-emacs@gnu.org; Fri, 29 Oct 2021 17:46:50 -0400 Original-Received: from mail-oi1-x22a.google.com ([2607:f8b0:4864:20::22a]:46709) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mgZi4-0000Hy-RU for help-gnu-emacs@gnu.org; Fri, 29 Oct 2021 17:46:50 -0400 Original-Received: by mail-oi1-x22a.google.com with SMTP id m11so10470474oif.13 for ; Fri, 29 Oct 2021 14:46:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=rOiORlZ4MoEg0JpgZoDKOj9JXvGtq1IUSFwVN7jrg/4=; b=KWeNvB5nXoo6WNHbhMJf1d3srWAwm/vKmi9q5oZgiY1kHvzScnyVwY5UnOcl+SWyKE ey/rzIuzupwuuMH9KtqPXEJ3k4d0+DKO3b/UgayVL/FZ6Bi+z6BwfcvQiVpzi5qj6hFS iuJJ88ayxNeR8tCs8spvF/gejhGJvAP0Jm/psOePJEysLVDuV0ynun+xFoynEhQW79KN JnJ48Fv8bCdZuDXx6CXrgayh/vlVdEFM5vLUsIlcPLdAIn8CUBzGLLwptu7pEvnuGng7 el5FkhPZl7v9rvu6+a7moAaygAS7dr8LFdFBWYjPc31kMKnw2OiKbEtg8AhtG5/yfZRn Z1Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=rOiORlZ4MoEg0JpgZoDKOj9JXvGtq1IUSFwVN7jrg/4=; b=hdDtNQXmHhyiZDBZtvLxHSmgomUx7L9wyt3OI0d35qKsONS77On/L0DZG61hQj8BIZ yM6/8KVByClOSkRuMc8ci687szKE2b1Rr64NMCwD2pT8N/mAxKEVdn7+Y18Bqvb7VH2K +Ui7TsFYftZOz3zAP0jVeo88+2XgJp6rNU70TXwWiT4zjepzWqCMc4GJSENZqwTEv3gJ d/fFSPn+d6HwlJs6b5dkh8/3RBnsEQSJT+LZLrSG0+2+N/el9xfurFmMgrKjG8DoDlTz ug9Iny2u3ZxE8sCUrrPYkbgYYmYJKBXmd0tYmKVinrGDoY6qj+OUrZ4Qn9iHz861LuLh 3gSA== X-Gm-Message-State: AOAM533BNkMn8H4eRMDVh+caUqeyP8pAOlRYtcptSkTYWISfh1XyZPJ/ fpVCSgSpZay9qQucKv/7lsIxXq0+X60= X-Google-Smtp-Source: ABdhPJy+aAzMR/Ow+K3SNlKBI6iiufScb6C0osICbuOb9chDtkRW8/Xwmu9iD4g1ClDRKg0pjP40Sw== X-Received: by 2002:aca:ea83:: with SMTP id i125mr15032567oih.26.1635544007737; Fri, 29 Oct 2021 14:46:47 -0700 (PDT) Original-Received: from smtpclient.apple ([2600:1700:2ec7:8c90:f0aa:334d:db56:3d62]) by smtp.gmail.com with ESMTPSA id f14sm2273779ots.51.2021.10.29.14.46.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Oct 2021 14:46:47 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3693.20.0.1.32) Received-SPF: pass client-ip=2607:f8b0:4864:20::22a; envelope-from=casouri@gmail.com; helo=mail-oi1-x22a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:134269 Archived-At: > On Oct 29, 2021, at 12:15 PM, Stefan Monnier via Users list for the = GNU Emacs text editor wrote: >=20 >> (mapcar #'cl--slot-descriptor-name >> (cl--struct-class-slots (get (type-of obj) 'cl--class))) >>=20 >> But I can=E2=80=99t get any further as I can=E2=80=99t find any = generic getter and >> setter for cl-struct=E2=80=99s. Something like slot-value. So close! >=20 > The position of the slot descriptor in `cl--struct-class-slots` = mirrors the > position of the slot in the actual objet, so you just need = `aref/aset`. Ah, silly me! >=20 > It would also make a lot of sense to replace/extend the useless > `:copier` thingy of `cl-defstruct` with something like the > `:constructor`, so you could say >=20 > (cl-defstruct (my-foo > (:copier my-foo-with) > (:copier my-foo-with-a (b a))) > a b c) >=20 > and then use (my-foo-with foo :c 42) and (my-foo-with-a foo 153 = "42=E2=80=9D) That=E2=80=99s cool. But my lazy fingers like better to write a single = function and use it for everything ;-) Yuan