dlang.org
dlang.org copied to clipboard
add bitfields documentation
Implementation: https://github.com/dlang/dmd/pull/13568
Thanks for your pull request, @WalterBright!
Bugzilla references
Your PR doesn't reference any Bugzilla issue.
If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.
@CyberShadow can we please have a way to find what the errors are with DAutoTest?
With DautoTest (unless you have LeTeX error in which case you're screwed) scroll all the way to the bottom of of the Build Log (click view).
In this case your problem is
Searching for tabs
./spec/struct.dd:134: b.x = 4;
Oh, I clicked on "base view". No errors there. I wonder what that is.
Anyhow, thanks! Hope it works now.
The text mentions unit
several times, but never says what it is.
@MrSmith33 it does now!
The dmd bitfields PR has been merged, under the -preview=bitfields switch. This one needs to be, too.
The dmd bitfields PR has been merged, under the -preview=bitfields switch. This one needs to be, too.
OK - As soon as it mentions the preview flag I will merge it
does the best practices section at line 44 still hold?
DeclaratorInitializer should also get a rule with BitfieldDeclarator in the grammar. DeclaratorIdentifier is only used for declarators after the first comma, while DeclaratorInitializer is used for the first declarator.
Another potential ambiguity in the grammar:
void f()
{
a: b;
}
The statement could be a bitfield with a
as type and b
as width, but it could also be a labeled statement with a
as label and b
as a statement. Bitfields are probably only allowed in classes and structs, but the grammar would also allow them in functions.
Edit: The text already says "Bit fields can only be fields in structs, unions and classes.", so that may be enough.
@WalterBright you may want to update this part: https://github.com/dlang/dlang.org/blob/ae9d2d63077db4daff8407280d4e6ece1547e942/spec/struct.dd#L90-L94
@maxhaton If bitfields are here to stay it would be good to merge this after adding any of the diff suggestions as you see fit. After that I can make a pull to fix https://github.com/dlang/dlang.org/pull/3190#issuecomment-1140274338
We really shouldn't document this useless trash feature that never passed the DIP review to be added to the language.
you may want to update this part
Done.
Ready to merge.
@dkorpel see https://github.com/dlang/dlang.org/pull/3190/files#diff-dee70e840ada3a820b3a373d649812b1157fd584ed0837e4a937ea3418f093e3R212
A preview switch doesn't imply it's not part of the language, there are preview switches for current language features.
Since bitfields do not influence anything else in the language semantics, there's no longer a purpose to putting bitfields behind a preview switch.