Ryan Joseph via fpc-pascal <fpc-pascal@lists.freepascal.org> schrieb am Mo., 4. Mai 2020, 18:58:
> > > > On May 4, 2020, at 2:12 PM, Michael Van Canneyt <mich...@freepascal.org> > wrote: > > > > 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. > > Yes but methods can be used without their class prefix so they aren't > comparable as identifiers the same way scoped enums are, because scoped > enums require the prefix to be valid at all. Always, that's fine, I just > wanted to make sure this wasn't an omission by accident. > Keywords have a higher precedence and are handled in the scanner. This will not be changed. > Speaking of that I just remembered something else. In Swift I liked that > they allowed scoped enums to be used without their prefix in the instance > that they are assigned to a compatible type, or in the correct context. > > For example if you have an enum > > TNames = (A, B, C); > > and a function > > SayNames(names: TNames); > > you can call it as SayNames([A, B]); and this is valid because of the > context. > > Is that possible to implement in scoped enums? It's a nice time saver to > not have to deal with the prefix when the context is correct but you still > get the namespace protection in the rest of the program. > No, because there could be a method A that returns a TName. Regards, Sven >
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal