Skip to content

add bitfields documentation #3190

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

WalterBright
Copy link
Member

Implementation: dlang/dmd#13568

@dlang-bot
Copy link
Contributor

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.

@WalterBright
Copy link
Member Author

@CyberShadow can we please have a way to find what the errors are with DAutoTest?

@thewilsonator
Copy link
Contributor

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;

@WalterBright
Copy link
Member Author

Oh, I clicked on "base view". No errors there. I wonder what that is.

Anyhow, thanks! Hope it works now.

@MrSmith33
Copy link
Contributor

The text mentions unit several times, but never says what it is.

@WalterBright
Copy link
Member Author

@MrSmith33 it does now!

@WalterBright
Copy link
Member Author

The dmd bitfields PR has been merged, under the -preview=bitfields switch. This one needs to be, too.

@maxhaton
Copy link
Member

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

@dlang-bot dlang-bot removed the stalled label May 10, 2022
@Moth-Tolias
Copy link

does the best practices section at line 44 still hold?

@tim-dlang
Copy link
Contributor

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.

@tim-dlang
Copy link
Contributor

tim-dlang commented May 28, 2022

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.

@AndrejMitrovic
Copy link
Contributor

@WalterBright you may want to update this part:

dlang.org/spec/struct.dd

Lines 90 to 94 in ae9d2d6

$(BEST_PRACTICE
$(OL
$(LI Bit fields are supported with the
$(LINK2 https://dlang.org/phobos/std_bitmanip.html#bitfields, bitfields) template.)
))

@ntrel
Copy link
Contributor

ntrel commented Dec 3, 2022

@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 #3190 (comment)

@adamdruppe
Copy link
Contributor

We really shouldn't document this useless trash feature that never passed the DIP review to be added to the language.

@WalterBright WalterBright force-pushed the Dbitfields branch 2 times, most recently from cfe1bf7 to 8f7a8c2 Compare November 6, 2023 06:38
@WalterBright
Copy link
Member Author

you may want to update this part

Done.

@WalterBright
Copy link
Member Author

Ready to merge.

Copy link
Contributor

@dkorpel dkorpel left a comment

Choose a reason for hiding this comment

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

Like Adam said, this feature hasn't been added to the language. This specification text makes it sound like it is. Perhaps it can be documented on a separate page for preview switches.

@WalterBright WalterBright requested a review from dkorpel November 6, 2023 19:43
@WalterBright
Copy link
Member Author

@dkorpel
Copy link
Contributor

dkorpel commented Nov 7, 2023

A preview switch doesn't imply it's not part of the language, there are preview switches for current language features.

@WalterBright
Copy link
Member Author

Since bitfields do not influence anything else in the language semantics, there's no longer a purpose to putting bitfields behind a preview switch.

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

Successfully merging this pull request may close these issues.