-
Notifications
You must be signed in to change notification settings - Fork 48
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
Add gem about bit manipulations #266
Conversation
2235ce9
to
a08501b
Compare
I think the gems section needs a navigation redesign. I agree that it's a cool idea to present these ideas in the tour format. But if you're going to have lots of gems as your PRs imply, they shouldn't be accessed from a dropdown. Preferably, the nav would link to a page with the gems grouped into beginner and advanced techniques. |
I fully agree - see #269 (restructure chapters) and #52 (vertical left menu). |
af8a5c3
to
58f5c14
Compare
Ready for destruction ;-) Out of interest does anyone know whether the fact that bitfields are no lvalues is a feature or bug?
|
@wilzbach I would consider this "as designed". Bitfields need to do bit fiddling internally and if lvalue ought to be supported an opaque type would have to be returned that writes changes back. At first this sounds doable but increased the complexity and maybe hurts performance a little.. |
|
||
### Simple bit manipulation | ||
|
||
D offers the following operator for bit manipulation: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
operators
After that I asked on IRC and I was told that there no apparent reason and it's just a missing feature. Hence I opened a feature request: https://issues.dlang.org/show_bug.cgi?id=16187 (I don't feel strongly about this, so if either the performance or complexity increase turns out to be true, I will weep a bit, but survive). |
No, @stonemaster is right - you can't do this without returning a proxy, which would be pessimization for the general case. The only that could help is something like |
BTW there several other interesting applications of bit manipulation that I didn't see mentioned:
In my experience |
|
||
As the compiler will add padding for variables with a size lower than the current | ||
OS memory layout (`size_t.sizeof`) e.g. `bool`, `byte`, `char`, it is recommended | ||
to start with fields of high alignments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
. Missing at EOL
a8b8640
to
60f09a4
Compare
|
||
A generalization is to test for blocks that are longer than 1. Hence | ||
a special read mask with the length of our block is needed | ||
and the data block is shifted accordingly before applying our mask; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
: instead of ;
60f09a4
to
aea3150
Compare
aea3150
to
b174cf0
Compare
Also based on #224 (will be rebased) - fixes #130.