unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Using funcall on inline functions
@ 2020-12-12 22:49 Eric Abrahamsen
  2020-12-12 23:28 ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Abrahamsen @ 2020-12-12 22:49 UTC (permalink / raw)
  To: emacs-devel

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




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-12-13 18:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-12 22:49 Using funcall on inline functions Eric Abrahamsen
2020-12-12 23:28 ` Stefan Monnier
2020-12-13 17:48   ` Eric Abrahamsen
2020-12-13 18:12     ` Stefan Monnier
2020-12-13 18:27       ` Eric Abrahamsen

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).