unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: emacs-devel@gnu.org
Subject: Do we need C's extern in Emacs Lisp?
Date: Tue, 29 Mar 2022 17:45:57 +0000	[thread overview]
Message-ID: <YkNF1XvLXRKSClzM@ACM> (raw)

Hello, Emacs.

This point came up in discussion with Lars over an old bug report.

In C, there is the keyword extern which means "defined somewhere else".
For a function, an example is

    extern foo (int bar);

, and for a variable, something like

    extern int foo;

..  This keyword has the property that the extern object can be defined
anywhere else in the program, and the object can be used in the current C
file without causing any errors or warnings.

Currently we do not have any equivalent in Lisp.  For example, if

    (defvar foo)

is in a Lisp file, then subsequent use of foo will generate an unknown
variable warning.

For example(2), if in the Lisp file there is

    (declare-function foo nil)

, this generates a warning when the function foo is later defined.

I think it would be useful to have some sort of "extern" facility in our
Lisp.

What do other people think?

-- 
Alan Mackenzie (Nuremberg, Germany).



             reply	other threads:[~2022-03-29 17:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-29 17:45 Alan Mackenzie [this message]
2022-03-29 21:09 ` Do we need C's extern in Emacs Lisp? Stefan Monnier
2022-03-31 20:59   ` Alan Mackenzie
2022-03-31 21:16     ` Stefan Monnier
2022-03-31  4:26 ` Richard Stallman

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=YkNF1XvLXRKSClzM@ACM \
    --to=acm@muc.de \
    --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).