Add extra suffixes for the built-in data types. #7896
Replies: 4 comments 2 replies
-
If this were to be done, I would reserve |
Beta Was this translation helpful? Give feedback.
-
Any news on this? We can consider also for (u)int8 and (u)int16 suffixes like:
other types (not common for suffixes):
bad idea (maybe?)
the suffix must be |
Beta Was this translation helpful? Give feedback.
-
Smaller than 32 bits is mostly pointless because that's the size of a normal (not 64 bit) integer on the stack. |
Beta Was this translation helpful? Give feedback.
-
Hope to have |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The idea of the suggestion is to be able to add suffixes for primitive types.
We already have the suffixes of:
10
= int,10U
= uint,10L
= long,10UL
= ulong10F
= float10D
= double10M
= decimalFor the (u)short (s)byte and char types it could be something:
10H
= short (or the suffix S)10UH
= ushort (or the US suffix)10B
= 10 in byte (causes an error if it is negative or exceeds 255)10SB
= 10 signed byte (causes an error if it is not in the range of -128 and 127)32C
= char? (ok, this one would be a little strange, I don't know if it's necessary that much)0x0000N
= nint/IntPtr (That one was weird too)0x0000UN
= nuint/UIntPtr (That one was weird too)Or another alternative to implement something similar to C++ literal operators. So each developer could implement their suffixes, for example calling
10ms
could translate toTimeSpan.FromMilliseconds(10)
.In cases of ambiguity, the parameter type, variable type or return type can help the compiler understand which literal operator it will use correctly. So even if, for example, two structs define the literal operator "ms" (to correspond to milliseconds) based on the type, it will apply the correct operator.
Beta Was this translation helpful? Give feedback.
All reactions