emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Question about DEFVAR_LISP_NOPRO


From: Gerd Möllmann
Subject: Question about DEFVAR_LISP_NOPRO
Date: Fri, 05 Apr 2024 17:10:51 +0200

I came across another esoteric question in the context of a moving GC.

Emacs contains has a few uses of DEFVAR_LISP_NOPRO, which is like
DEFVAR_LISP, except that it does not staticpro the variable.

  #define DEFVAR_LISP_NOPRO(lname, vname, doc)  \
    do {                                        \
      static struct Lisp_Objfwd const o_fwd     \
        = {Lisp_Fwd_Obj, &globals.f_##vname};   \
      defvar_lisp_nopro (&o_fwd, lname);        \
    } while (false)

Example:

  DEFVAR_LISP_NOPRO ("font-weight-table", Vfont_weight_table,
                 doc: /*  Vector of valid font weight values. ... */);
    Vfont_weight_table = BUILD_STYLE_TABLE (weight_table);
    make_symbol_constant (intern_c_string ("font-weight-table"));

Here a symbol is defined which has a value that is forwarded to the
static globals.f_Vfont_weight_table, but that static is not staticpro'd.

My question is simply: What the heck?

I understand that this can be necessary, in rare cases, when one needs to
staticpro stuff before defvar_lisp is usable, during Emacs' startup. I've
done that myself, but the other cases make no sense to me.

Does someone perhaps have an idea what other reasons could be to use
DEFVAR_LISP_NOPRO?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]