[fpc-pascal] Name collisions in scoped enums

Bjarne Bäckström m9411 at abc.se
Tue May 5 12:45:04 CEST 2020



> 5 maj 2020 kl. 07:19 skrev Sven Barth via fpc-pascal <fpc-pascal at lists.freepascal.org>:
> 
> Am 05.05.2020 um 04:16 schrieb Ryan Joseph via fpc-pascal:
>> 	
>> 
>>> On May 4, 2020, at 10:44 PM, Michael Van Canneyt <michael at freepascal.org> wrote:
>>> 
>>> That is how enums work by default in Pascal.
>>> 
>>> If you don't force scoped enums, you can still scope them.
>>> 
>>> if you use
>>> $scopedenums on then you simply force the use instead of having it optional.
>> But the names collide then, that's the whole point. We want to protect against name collisions and we don't want to type long prefix names every time. Scoped enums fixes half of that by formalizing the prefix syntax but you still need to type it even when it could be inferred by context.
>> 
>> Swift figured out how to do this and so should Pascal imo.
> 
> Surprise: Pascal is /not/ about writing less. Pascal is about writing correct code.

Couldn't agree more!

/Bjarne.

(back to lurking)



More information about the fpc-pascal mailing list