Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Byte literals #111

Closed
AnthonyDGreen opened this issue Jun 28, 2017 · 6 comments
Closed

Byte literals #111

AnthonyDGreen opened this issue Jun 28, 2017 · 6 comments

Comments

@AnthonyDGreen
Copy link
Contributor

There's no way to express a Byte in VB. It can be a pain in some cases involving Option Strict. It also seems arbitrary since all the other numeric types have a suffix. We discussed this in a previous LDM and came up with SB and UB as the literal suffix for signed byte and unsigned byte respectively.

Dim signed = 1SB
Dim unsigned = 255UB

Seems cheap and consistent.

@AnthonyDGreen AnthonyDGreen added this to the VB15.x candidate milestone Jun 28, 2017
@craigajohnson
Copy link

Seems like a no-brainer.

In addition to SB, could just B also be added for (what I consider to be) the most common case - signed byte (either 1SB or 1B would be accepted)?

@reduckted
Copy link
Contributor

Why SB? Why not just B. It consistent with the other type literal characters.

Literal type character Data Type
S Short
US UShort
I Integer
UI UInteger
L Long
UL ULong

https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/data-types/type-characters#forced-literal-types

@AnthonyDGreen
Copy link
Contributor Author

Because in Hex B is a digit. Also because Byte is inconsistent with the other types in that the "default" is unsigned, so we weren't sure people would see 255B and know that it's (crap, I've forgotten while writing this what it is)... Signed (and an overflow, technically). Lastly, since UB is by far the more common case it's not that important to optimize SB.

@reduckted
Copy link
Contributor

Because in Hex B is a digit.

Ah yes, good point, because &H1B is an Integer today, but would become ambiguous if we used B as the type char.

I'm good with UB and SB then. Anything will be better than having to use CByte() 😀

@craigajohnson
Copy link

^^ same as @reduckted! I hadn't thought of a suffix after a hex literal but of course.

@KathleenDollard
Copy link
Contributor

Dupe of #213

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants