unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Arthur Miller <arthur.miller@live.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: "Paul W. Rankin" <pwr@bydasein.com>, emacs-devel@gnu.org
Subject: Re: declare function/macro private
Date: Mon, 07 Jun 2021 20:24:33 +0200	[thread overview]
Message-ID: <AM9PR09MB497734752447F381D88D6A4696389@AM9PR09MB4977.eurprd09.prod.outlook.com> (raw)
In-Reply-To: <jwvo8cipf74.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sun, 06 Jun 2021 22:54:41 -0400")

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>>>> Of course there's already the convention of prefix--my-private-function, but
>>> What would be the difference between this convention and your proposed declaration?
>> Stefan, you must have missed my followup reply:
>
> No, I'm still wondering what it is you find to be different.
>
> My current guess is that you fear that "--" has currently been used
> carelessly and imposing a more "structured" meaning to it after the fact
> will hence introduce problems, whereas your declaration would come right
> away with an associated "precise" meaning.
>
> If so, I agree to some extent, but:
> - As mentioned your declaration would suffer from the difficulty of
>   clarifying "internal to what" since sometimes a function is internal
>   to a file, sometimes to a multifile package and sometimes to a subset
>   of a file.  Of course, that can be solved by adding an extra argument
>   to your annotation, but:
> - your annotation is placed on those functions that are internal, which
>   (as a coder) are those functions which I'd rather not burden with too
>   much extra annotations, otherwise I'll just not bother declaring them
>   as internal (which is what we had before the "--" convention).
> - As long as the effect is just a few font-lock-warning faces here and
>   there, I think the problem is harmless enough (and it does point to
>   real misfeatures in many cases, so it would help improve the code).
>
>> I think requiring a program to explicitly declare something as internal will
>> cause less trouble than adding a kind of compiler heuristic for "--" symbol
>> names because there are likely plenty of those where people have used the
>> name with the perspective that it's just a hint and doesn't actually do
>> anything. e.g. `imenu--index-alist' is supposedly internal but any elisp
>> program hooking into Imenu needs to use this variable.
>
> Yes, currently it's a bit of a wild west because the "--" has no effect,
> but maybe it's time to impose some order on this, indeed.
>
>> Also I just dislike computer heuristics.
>
> It's not a heuristic.
>
>>>> my thinking here is that a program could declare a function/macro as
>>>> private, then the compiler could signal a warning/error if that function
>>>> appeared in a library outside the library it was defined and
>>>> declared private.
>>> We don't have a definition for "library", sadly.
>> M-x find library says otherwise. But the definition of a "library" is
>> inconsequential. Using "file" might be more helpful.
>
> But "file" is the wrong granularity for many Gnus-internal definitions
> (and same applies to all multifile packages).  So what would use for
> those if your declaration are only for file-local internal definitions?
>
>

I think one of problems with '--' is that is *relatively* new
convention. Lot's of old code in Emacs sources does not follow it, and
lot's of 3rd party packages does not follow it. Some older 3rd party
packages use different conventions like 'prefix/function-name' or
'prefix:function-name', where prefix is package name. As Ingebritsen
wrote in some other mail yesterday you could have Emacs highlight
syntax, but then there should be some way to tell Emacs what prefix is.

What OP propose is to have programmatic control over what is
"public/private", but in my opinion, as he suggestes, it would be quite
tedious to type for each and every "private" function an explicit
declaration as he proposes. People would probably not do it, just like
they don't care to write proper javadocs, doxygen docs and other
"proper" things that require explicit work.

But if Emacs can auto detect prefixes as "private", than it is
completely different game.

Also there should be some way to distinguish between code in same
package which shouldn't produce warnings and client code that uses
library where warnings should be emited if a "private" function is used.



  reply	other threads:[~2021-06-07 18:24 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-06  4:27 declare function/macro private Paul W. Rankin via Emacs development discussions.
2021-06-06  7:09 ` Omar Polo
2021-06-06  7:18   ` Paul W. Rankin via Emacs development discussions.
2021-06-06  9:53 ` Lars Ingebrigtsen
2021-06-06 12:43   ` Paul W. Rankin via Emacs development discussions.
2021-06-08  9:43     ` Lars Ingebrigtsen
2021-06-08 17:26       ` Robin Tarsiger
2021-06-06 18:05 ` Stefan Monnier
2021-06-06 18:12   ` Tassilo Horn
2021-06-06 20:12     ` Stefan Monnier
2021-06-07  0:51       ` Paul W. Rankin via Emacs development discussions.
2021-06-07  1:37         ` Arthur Miller
2021-06-07  1:43           ` Paul W. Rankin via Emacs development discussions.
2021-06-07 13:38             ` Arthur Miller
2021-06-07  0:59   ` Paul W. Rankin via Emacs development discussions.
2021-06-07  2:54     ` Stefan Monnier
2021-06-07 18:24       ` Arthur Miller [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-06-07  3:35 Boruch Baum
2021-06-07  4:49 ` Paul W. Rankin via Emacs development discussions.
2021-06-07  5:59   ` Stefan Monnier
2021-06-07  6:45     ` Paul W. Rankin via Emacs development discussions.
2021-06-07 12:39 ` Eli Zaretskii
2021-06-08  1:14   ` Boruch Baum
2021-06-08  4:20     ` Arthur Miller
2021-06-08  5:49       ` tomas
2021-06-08 15:46     ` Stefan Monnier

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=AM9PR09MB497734752447F381D88D6A4696389@AM9PR09MB4977.eurprd09.prod.outlook.com \
    --to=arthur.miller@live.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=pwr@bydasein.com \
    /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).