[fpc-devel] Minor debate with ISO standard on case blocks

Stefan Glienke sglienke at dsharp.org
Tue Jul 30 13:25:41 CEST 2019


Actually I prefer a compiler error/warning on such cases - so being able to write an exhaustive case is a very good option over eventually getting runtime errors - oh, yeah we all have exhaustive unit tests don't we? ;)

TypeScript for example has the never type which can be used to write a compiletime safe exhaustive switch statement.


> On 30 July 2019 at 12:26 Paul Breneman <Paul2006 at BrenemanLabs.com> wrote:
> 
> 
> This message thread has been interesting to read.
> 
> I just realized today that I dealt with similar issues in Delphi 19 
> years ago.  This is discussed in the good Microsoft Press book *Code 
> Complete* by Steve McConnell.  Using the default else block of a case 
> statement to show a program error message is exactly what is recommended 
> on pages 319-320 (and the same thing for repeated if statements on page 
> 316).  I don't know if this directly applies, but it was fun to renew a 
> few brain cells by looking at old emails.
> 
> If I add an enumerated type and forget to update some of my code, I'd 
> like to get an error message when the unchanged code is run.
> 
> Regards,
> Paul
> www.ControlPascal.com
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


More information about the fpc-devel mailing list