[Proposal]: Extended identifier syntax #7966
Unanswered
leppie
asked this question in
Language Ideas
Replies: 3 comments 6 replies
-
As documented in our README, all proposals start out as discussions, not issues. |
Beta Was this translation helpful? Give feedback.
1 reply
-
Would this make 'unspeakable' identifiers (e.g. those used for display classes) actually 'speakable'? |
Beta Was this translation helpful? Give feedback.
3 replies
-
I am curious if an F#-style verbatim identifier feature would address this use case. (I couldn't find prior issues for this, but they must exist, here or elsewhere..) e.g. in F# we can say |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Extended identifier syntax
Summary
Allow non-standard identifier syntax in C#.
Motivation
Allow C# to reference any allowable CLR identifier in assemblies produced by non-C# languages for interop purposes.
Detailed design
Some languages do not conform to the C# identifier syntax, but still are valid within the CLR specification.
This proposal introduces a (lexical) syntax extension that is compatable with the C# lexical specification and also allow other language names to be referenced without having to resort to reflection or other means (ie post-processing or raw IL).
In the spirit of Markdown, I suggest the ability to escape any identifier between 2 backquotes.
Examples:
The resulting text between the two backquotes will exactly reference (and resolve, when used) a single valid CLR identifier.
Usage (using and calling a static method);
Justification
Shameless plug: https://github.com/IronScheme (but specifically IronScheme.Glue.il needed for interop).
Another common use case would be preserving quoted SQL identifiers. See example above.
Drawbacks
It is ugly, but it is ugly for a reason. General usage should not be encouraged.
Potential parsing issues with comments, preprocessor directives and other existing lexical tokens.
Alternatives
There are no static alternatives except raw IL or post-processing like Fody.
Unresolved questions
To discourage usage even more, a compiler flag/property could/should be added.
Design meetings
Beta Was this translation helpful? Give feedback.
All reactions