2022-04-12

c# type identifiers should be capitalized to protect future keywords

4.12: news.adda/lang/c#/
type identifiers should be capitalized to protect future keywords:

. when you are working with an evolving language,

you run the risk of creating identifiers

that the language will later want to use as keywords, 

reserved by the system.

. to support backward compatibility

if your language has a syntax like C#,

the only conflict is going to be when it is

your type identifiers that have become keywords,

because for all other identifiers

context can determine whether the keyword

has a system versus a local meaning.

. C# keywords will always be lower-case letters,

thus, your type identifiers must include

some upper-cased or non-alphabet characters,

or type identifiers should all be capitalized.


summary of @jaredpar 2022/04/11:

https://blog.paranoidcoding.com/2022/04/11/lowercase-type-names.html

. in the next version of C#, 11,

the compiler issues a warning when a type identifier 

is declared with all lower-case letters. 

The warning is alerting customers to 

types that may become keywords in future versions.

. C# has a strong compatibility guarantee;

so, whenever C# introduces a new keyword into the language 

it must be a conditional keyword:

This means that the C# language must consider both

when the identifier is used as a keyword

and when it’s used as a type.

. and to be able to distinguish that difference,

the language has had to complicate the syntax

surrounding new keyword

so that it can't be confused with a type identifier.

. if your type identifiers must be capitalized,

this allows the C# language to begin

moving away from conditional keywords

and allow for simpler syntax.


No comments:

Post a Comment