all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: "Óscar Fuentes" <ofv@wanadoo.es>
Cc: emacs-devel@gnu.org
Subject: Re: good examples of Emacs modules?
Date: Fri, 01 Apr 2016 17:07:50 +0300	[thread overview]
Message-ID: <8360w1toax.fsf@gnu.org> (raw)
In-Reply-To: <87h9fl5ull.fsf@wanadoo.es> (message from Óscar Fuentes on Fri, 01 Apr 2016 15:25:42 +0200)

> From: Óscar Fuentes <ofv@wanadoo.es>
> Date: Fri, 01 Apr 2016 15:25:42 +0200
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > I think you want to wrap some kind of "handle" that is meaningful to
> > libgit2 into a user-ptr object (see the existing docs about modules
> > for details about these).  A user-ptr object has a finalizer, a
> > function that is called by GC when the object goes out of scope.
> 
> This means that GCing the object is unpredictable, right?

It's as predictable and as unpredictable as what you have with any
other Lisp object.  As long as the object is referenced, it will not
be GC'ed.

> Also, if the API uses a struct as the session object, you need to
> store it somewhere and expose a pointer to it to the Elisp code;
> that is, you can't put arbitrary data on the Elisp memory space.

The user-ptr object is precisely the way to produce a Lisp object that
holds such a pointer, so I'm not sure why you are describing this as
some kind of problem: it's a solution, not a problem.  You allocate
memory for the struct, store the info there, then wrap the resulting
pointer in user-ptr, and that's it.  (The finalizer should free the
memory and perform whatever other cleanup is needed.)  If this is
somehow problematic, please tell why.



  reply	other threads:[~2016-04-01 14:07 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-30 23:17 good examples of Emacs modules? Paul Eggert
2016-03-31 14:49 ` Aurélien Aptel
2016-03-31 15:34   ` Óscar Fuentes
2016-03-31 16:53     ` Eli Zaretskii
2016-03-31 17:07       ` Óscar Fuentes
2016-03-31 17:39         ` Eli Zaretskii
2016-03-31 20:23           ` Óscar Fuentes
2016-03-31 21:29             ` Aurélien Aptel
2016-03-31 21:59               ` Óscar Fuentes
2016-04-01  7:18                 ` Eli Zaretskii
2016-04-01 13:20                   ` Óscar Fuentes
2016-04-01 14:02                     ` Eli Zaretskii
2016-04-02  2:10               ` Syohei Yoshida
2016-05-03 20:48                 ` Philipp Stephani
2016-05-03 22:16                   ` Stefan Monnier
2016-04-01  6:23             ` Eli Zaretskii
2016-04-01 13:25               ` Óscar Fuentes
2016-04-01 14:07                 ` Eli Zaretskii [this message]
2016-05-03 20:54   ` Philipp Stephani

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8360w1toax.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=ofv@wanadoo.es \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.