On 2025-12-29 03:12, Bruno Haible wrote:
It would be *horrible* to have a function defined as

   void window_size_changed (int, int, int w, int)
   { ... }

It is much better to not omit the identifier:

_GL_UNNAMED / UNNAMED does that.


I can't take a style guideline from Bjarne Stroustrup
seriously.

Hmm, well, although I've not been a fan of many of Stroustrup's style decisions, my point was more that there is a school of thought that says that sometimes giving something a name is more trouble than it's worth. It's not just Stroustrup saying this: it's deeply embedded in several programming languages, e.g., the "_" anonymous identifier in ML, Prolog, Go, and Rust.

I found many
arguments that were formerly used in old Emacs versions but the code had
bitrotted. The patch to fix this, which I have not applied yet, is over
4000 lines long; it does not use MAYBE_UNUSED or UNNAMED, but simply
omits arguments.

I hope it does not omit the identifiers?

It's OK, it uses UNNAMED.


Maybe we should have a way to declare that a function is meant to be an
implementation of a function type / API ?

There is a way to do that in C. In the .h file you do something like this:

  typedef int desired_API(char *);

and in client code you do this:

  desired_API f;
  int
  f (char *p)
  {
    ...
  }

I don't see this style used much, as one gets the type checking anyway when one passes f to a function expecting a function of the appropriate type. I suppose that if GCC had a compiler switch saying "warn about unused arguments only if the function has not already been declared that way", that would remove some of the need for the UNNAMED gingerbread. Not sure how well that'd go over with the GCC folks, though.

Reply via email to