Subject: bug#75964: Switching the Emacs build to -Wswitch-enum in src/

From: Eli Zaretskii <[email-masked]>
Date: Sun, 02 Feb 2025 19:35:41 +0200

> Date: Sun, 02 Feb 2025 17:02:04 +0000
> From: Pip Cet <[email-masked]>
> Cc: [email-masked], [email-masked], [email-masked], [email-masked], [email-masked]
> 
> "Eli Zaretskii" <[email-masked]> writes:
> 
> > This is an example of code where some value of an enumeration need
> > special handling, and the rest don't need any handling at all.  IMO,
> > we should ask ourselves what are we trying to accomplish by spelling
> > out all of the "other" values instead of just 'default'?  If we only
> > care for a handful of values, what kind of errors could slip us if we
> > use 'default'?
> 
> As someone who's not very familiar with the bidi code, I would feel most
> comfortable if this switch, with all cases, were in an inline function
> which decides whether we set l2r_seen, r2l_seen, or neither, in this
> context.  Ideally, in my case, with further comments, though trying to
> understand this code without studying the Unicode Bidirectional
> Algorithm will always be foolish...

The bidi.c code is in many places in the shape it is because it tries
to closely follow the description in the UBA, so as to make the
understanding of what the code does easier without drowning it in
comments.

If the goal here is to make sure we never miss a type is to invent a
new category, which includes only the 4 types mentioned in the switch,
and then do the switch only for that category.