Allow "@" character as a prefix to enable keywords to be used as identifiers. #3510
Replies: 4 comments 3 replies
-
|
Beta Was this translation helpful? Give feedback.
-
Can't you use another character like |
Beta Was this translation helpful? Give feedback.
-
I'm pretty sure our JSON marshaller supports alt-names for fields and it can understand when a field in a struct differs from the encoded field. That said, serialization is the only place where this syntax is useful. If you were fine with
To specify a different encoded field name. The benefit of this feature doesn't extend beyond the problem of serialization and can't be abused like the |
Beta Was this translation helpful? Give feedback.
-
I know this is an old post but there is zero need for this whatsoever. Why do you need to use a keyword as an identifier? Every place where I think people would think it is necessary is the following:
|
Beta Was this translation helpful? Give feedback.
-
Idea from C#
Allow "@" character as a prefix to enable keywords to be used as identifiers.
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#643-identifiers
e.g. keywords like
Useful for json serialization so you don't need to add attributes to map the fields.
C# example
not sure if using @ will clash with the Odin syntax
if so another char could be chosen ofc
Beta Was this translation helpful? Give feedback.
All reactions