Description
Today in VB all the integral literal types have a type suffix (S, US, I, UI, L, UL). There isn't one for byte, which is mostly fine, but it's still incomplete. And for the Option Strict
crowd this forces them to write CByte(-1)
. We talked about how to change the language to avoid this error but after some thought I concluded that the error was not in the language for implicitly converting -1
(implicitly an Integer
) to the SByte
type but with Option Strict
for being stupid. C#, for example, doesn't forbid this implicit conversion. We should probably fix Option Strict
to not report an error for this conversion but that's orthogonal to whether there's a native syntax for 8-bit integer types in the language.
All that being said, we talked it over in the LDM some time ago and decided to just add suffix characters for these two types. After much debate we settled on UB
for unsigned bytes and SB
for signed bytes. F# for example uses Y
and UY
but that's not very intuitive. The reason we picked these is two fold:
- Because all of the other integral types are signed as standard (CLS-compliant) and use an extra character for the unsigned types we weren't sure if we should go for consistency and use
B
andUB
, or if we should prefer the CLS-compliant unsigned byte and put the extra character on the signed byte,B
andSB
. B
is a valid digit character in the hexadecimal base. We could just restrict these characters to decimal but hexadecimal byte literals seem like an awfully common use case of the byte type.
I guess the counter argument would be that since bytes already take up so few characters adding two more to the end starts to really obscure their value, e.g. &HFFUB
or 255UB
. It seems like a harmless and natural extension to the language though.