unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: emacs-devel@gnu.org
Subject: Using funcall on inline functions
Date: Sat, 12 Dec 2020 14:49:28 -0800	[thread overview]
Message-ID: <87bleyd4hz.fsf@ericabrahamsen.net> (raw)

I might be doing something wrong here, but I'm having trouble using
funcall+inline+general variable. I thought that one of the advantages of
an inline was that they were effectively defined as both macros and
functions.

It's a slightly convoluted situation, bear with me, here's the simplest
I can get it:

(cl-defstruct ebdb-record-cache
  (alt-names nil :type list))

(defclass ebdb-record ()
  ((cache :type ebdb-record-cache))) 

(define-inline ebdb-record-alt-names (record)
  (inline-quote (ebdb-record-cache-alt-names
                 (slot-value,record 'cache))))

(define-inline ebdb-add-to-list (list-var element)
  (inline-quote (when, element
                  (cl-pushnew, element, list-var :test #'equal))))

(let ((listfunc #'ebdb-add-to-list)
      (name-string "Bob's new name"))
  (funcall listfunc
           (ebdb-record-alt-names <some-record>)
           name-string))

Maybe this a bit overboard in terms of indirection, but it ought to
work, yes? What happens is that the funcall form returns the correct
list (the contents of the record's cache's alt-names slot, with the
name-string added) but the cache's actual slot value is not altered.

It wouldn't kill me to duplicate some code and use `ebdb-add-to-list' in
the function position, but I'd like to know why this doesn't work.

Thanks!
Eric




             reply	other threads:[~2020-12-12 22:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-12 22:49 Eric Abrahamsen [this message]
2020-12-12 23:28 ` Using funcall on inline functions Stefan Monnier
2020-12-13 17:48   ` Eric Abrahamsen
2020-12-13 18:12     ` Stefan Monnier
2020-12-13 18:27       ` Eric Abrahamsen

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=87bleyd4hz.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --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).