<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Ryan Joseph via fpc-pascal <<a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>> schrieb am Mo., 4. Mai 2020, 18:58:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
> On May 4, 2020, at 2:12 PM, Michael Van Canneyt <<a href="mailto:michael@freepascal.org" target="_blank" rel="noreferrer">michael@freepascal.org</a>> wrote:<br>
> <br>
> Methods can't be keywords either, unless prefixed with &.<br>
> <br>
> 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.<br>
<br>
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.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Keywords have a higher precedence and are handled in the scanner. This will not be changed. </div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
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.<br>
<br>
For example if you have an enum <br>
<br>
TNames = (A, B, C);<br>
<br>
and a function <br>
<br>
SayNames(names: TNames);<br>
<br>
you can call it as SayNames([A, B]); and this is valid because of the context.<br>
<br>
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.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">No, because there could be a method A that returns a TName. </div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div></div></div>