[fpc-devel] [Suggestion] Enumeration range-check intrinsic

Sven Barth pascaldragon at googlemail.com
Sat Jul 6 00:50:52 CEST 2019


Am 05.07.2019 um 22:34 schrieb J. Gareth Moreton:
>
> It feels like a very convoluted way to implement a safe means of 
> reading an enumeration from a file, but given that that reading 
> incorrect data files is one of the main causes of enums taking on 
> invalid values, I have to say that this is the best solution should we 
> not be allowed the "is" operator or an intrinsic.  If that is the 
> case, then I propose this gets added to TStream!
>
At least it hides the gruesome details, cause you only need to call 
ReadEnum<> (or ReadRange<>)... And maybe the code the compiler generates 
can even be optimized further. :)

Regards,
Sven


More information about the fpc-devel mailing list