Skip to content

Proposal: (Minor) Unkeyword built-in types (e.g. int) #207

@ashmind

Description

@ashmind

Problem

Currently built-in types (int, string, etc) in C# are full keywords.
However, some of those names might be useful variable/parameter names depending on the situation.

For example:

foreach (var @byte in hash) ...
foreach (var @char in name) ...
var @object = json.ToObject();

At the moment, these names require @-escaping -- which is not well-known to most people and rather inconvenient.

Proposed solution

Change grammar so that those type keywords are well-known type names instead of full keywords.
This would be similar to how var is handled at the moment.

Pros:
  1. Less special names in the language -- more choice for identifier names
  2. More consistent type identifier handling -- both var/dynamic and int will be same for the parser
Cons:
  1. Colorizers will have to be smarter (but then they already have to, due to var/dynamic)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions