Its a basic concept...
Structs, Unions etc can be nameless..
What this means is you can address the members of this field as if they were in the parent struct/Record, there
is no requirement for using a additional identifier.
As for alignment, especially bit fields, This will group the items together as a whole but not require you to
add additional identifier. In other words, it uses the name space of the parent of that record.
Now getting to the variant record..
You can have a variant record at the end and it requires no identifier, just the overlapping members of that
location. However, to get that work before the end of the Record is a nightmare without forcing a sub identifier..
Currently when you use a Variant record the END statement also ENDS the main record, why that ever was
done that way is beyond me., but at least you aren't forced to add a sub ID to it...
If you wrap a variant with a Record you can then have a variant before the end of the record however, you
now are forced to also have a Identifier which in many I don't want. I want the fields of the variant to be
in the same name space as the host Record of the variant and if the RECORD is nameless this means the
Name Space will be that of the host before...
Let me see if I can give an example
MyRecord = Record
Record
Case
0:(A:Word;
1:(B.Short[10]);
End;
SomeByte:Byte;
End;
I want to do this.
MyRecord.A := 1;
or
MyRecord B:= 'hello';
But because we don't have nameless records this is what we need to do.
MyRecord = Record
Afield: Record
Case
0:(A:Word;
1:(B.Short[10]);
End;
SomeByte:Byte;
End;
MyRecord.AField.A := Whatever...
MyRecord.Afield.B := 'Something';
Of course the Scope of the A,B in the nameless record version will also be in the same scope as
the SomeByte, you'll need unique ID's for those of course..
But this solves cryptic variant cases and can be used for Bit alignment...
currently as noted in another thread, the empty Record can be used as a trialling pointer.