[fpc-devel] "Case statement does not handle all possible cases" Warning

Sven Barth pascaldragon at googlemail.com
Sun May 19 09:34:27 CEST 2019


J. Gareth Moreton <gareth at moreton-family.com> schrieb am So., 19. Mai 2019,
05:17:

> Yes, I'm jumpy, especially as you always like to open your responses
> with a direct insult of some kind - yes, I checked.  You want to kill me
> or ban me from the mailing list, go right ahead. I'm sure Free Pascal
> will survive without me.
>

First of Ralf Quint is not part of the FPC development team, thus he has no
power over the mailing list or whether *we* (the development team) accept
your contributions.

Second the term "lazy programmer" is a known term in development:
https://wiki.c2.com/?LazyProgrammer
So he's not calling you "lazy" personally, but he's pointing out that your
argumentation is that of a "lazy programmer".

I just feel that in this case, it should be a note, not a warning,
> unless you're compiling under a dialect of Pascal (e.g. Extended) that
> is stricter in its interpretation of the whitesheet and demands an error
> be returned.
>

No, I don't think so. The compiler might generate quite some hints and
notes some of which might be false positives (take the "uninitialized
variable" in context of "var" parameters) and thus this note/hint would be
lost among the noise.

Also you need to keep in mind that enums are not necessarily static over
the lifetime of the software. E.g. (using the compiler as an example) a new
def type could be added. If you now haven't added empty else-clauses to the
case-statements you'll now get a nice warning for every such case statement
so that you can be reasonably sure you caught all.

At my work (where we use MSVC) we enabled the compiler's warning for this
reason.

P.S. And while I agree that one should not merely look towards C and C++
> for inspiration (I see the practice of lowercasing everything and not
> having a space between operators and operands as 'colonisation', for
> lack of a better term), it seems that we are a little inconsistent when
> it comes to that, given that Free Pascal supports the C-style assignment
> operators now.
>

The C-style operators are merely syntactic sugar and don't do any
optimization of the operation. Also they can't be used on properties.
Not to mention that not everyone likes their use (I for example am
pondering whether I should add a "$COperators Off" to FPC fpcdefs.inc so
that contributors won't be tempted to use them).

Regards,
Sven

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20190519/0f51799c/attachment.html>


More information about the fpc-devel mailing list