[fpc-pascal] Name collisions in scoped enums

Michael Van Canneyt michael at freepascal.org
Mon May 4 09:12:19 CEST 2020



On Mon, 4 May 2020, Ryan Joseph via fpc-pascal wrote:

> 
>
>> On May 4, 2020, at 12:40 PM, Sven Barth <pascaldragon at googlemail.com> wrote:
>> 
>> No, keywords have a higher priority than identifiers, their context doesn't matter (e.g. you can't have a method named "File" either though one could apply the same reasoning here). If you want to use keywords you have to escape them using "&".
>
> Methods could be called without a prefix and scoped enums must under all circumstances use their prefix right? 
> I thought that made them unique in this regard. It would be nice to have those names freed up also if it was safe.

Methods can't be keywords either, unless prefixed with &.

It's not safe to change this, that's why a keyword is a keyword: 
it supersedes all identifiers, it is part of the language.

If you really must use keywords, just use (&File,&Array), that's what the & is for.

Michael.


More information about the fpc-pascal mailing list