Is many more easy understand if make do and not alone read ;D
I think there is a way to embed everything together as well.
In the first case it is better to put the word "packed", and in the second case-not necessarily. For example, in Delphi 10.3 Implicit Packing of Fields with a Common Type Specification (http://docwiki.embarcadero.com/RADStudio/Rio/en/Internal_Data_Formats_(Delphi)#Implicit_Packing_of_Fields_with_a_Common_Type_Specification) work only with {$OLDTYPELAYOUT ON} directive.
type TAXRegister = record AL, AH: Byte; end; TCPURegister = packed record ...
Yes, you can declare a field as record directly inside the declaration of the main record:I have not seen documentation that says that the word (bit)packed also applies to nested record types. Yes, now it works because of the compatibility with Delphi, but it does not look logical. After all, if you declare a nested structure as a separate type, that is, without words packed, and use it already in the declaration, you will get a different result. So I think this type declaration is wrong, i.e. you must write (bit)packed for both "record".
I have not seen documentation that says that the word (bit)packed also applies to nested record types. Yes, now it works because of the compatibility with Delphi, but it does not look logical.
After all, if you declare a nested structure as a separate type, that is, without words packed, and use it already in the declaration, you will get a different result.
Moreover, the code like "Include(Set, Flag)" or "if Flag in Set then" is not only more readable […]
[…] but also more efficient.
@Thaddy: can you show me a practical example of using such a set? Any pros and cons?
If this is not clear enough I can give you an example based on the Raspberry Pi GPIO (but that is atm not very clean, since I change it too much and it is not under version control, unlike most of my code)
But I hope you appreciate the more elaborate example.