dotnet / dotnet/vblang

Type suffix for `Byte` and `SByte` types

Open
#213 14 comments 4 reactions 0 assignees View on GitHub
Approved-in-Principle LDM Considering Proposal
Dominant language
No language data
Stars
328
Forks
71
PR merge metrics
No merged PRs in 30d

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:

1. 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` and `UB`, or if we should prefer the CLS-compliant unsigned byte and put the extra character on the signed byte, `B` and `SB`.
2. `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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.