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

replace binary literals with hex #4779

Merged
merged 1 commit into from
Sep 14, 2016
Merged

Conversation

WalterBright
Copy link
Member

Binary literals are borderline illegible, especially with the weird _ placement. Use hex values like everywhere else.

@WalterBright WalterBright added the Review:Trivial typos, formatting, comments label Sep 13, 2016
out_ = 2, /// ditto
ref_ = 4, /// ditto
lazy_ = 8, /// ditto
return_ = 0x10, /// ditto
Copy link
Member

@schveiguy schveiguy Sep 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the consistency of style and alignment in the original.
Can this be:

0x01,
0x02,
0x04,
0x08,
0x10,

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used to do things that way, but over time changed to the method used in the PR. The visual noise just makes it take that much longer for my brain to process. Having leading 0's is not appealing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Over time, I've also come to the conclusion that the binary literal syntax is just a mistake. Hex is much easier to grok (don't have to put a pencil on the screen and count positions). Ironically, other languages are starting to adopt it :-) so I'm out of step as usual.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't need to have leading zeros. Another possibility would be:

   1,
   2,
   4,
   8,
0x10,

What I like about the alignment is when you compare what bit positions are set from multiple values, they are easier to compare.

I also think the binary is quite useless, and prefer hex. It took me a while when I started, but learning what all the hex values are is not that bad.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And of course, the placement of the _ in the original was atrocious. It should ONLY ever be put on byte or nibble boundaries.

@9il
Copy link
Member

9il commented Sep 14, 2016

Auto-merge toggled on

@9il 9il merged commit bf64e68 into dlang:master Sep 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Review:Trivial typos, formatting, comments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants