Even if I had heard that according to the original definition of Niklaus Wirth Pascal, everything should work as you expected, I have not seen this behavior in Delphi, starting with its ancestor, Turbo Pascal 2.0 . A quick look at FreePascal showed that its behavior is the same. As stated in the Delphi Documentation :
You can read or write in any field of any option at any time; but if you write in a field in one embodiment, and then in a field in another embodiment, you can rewrite your own data. The tag, if any, functions as an additional field (of type ordinalType) in the non-invariant part of the record. "
As for your intention, as I understand it, I would use two different classes, like
a = class b : Integer end; aEnabled = class(a) c: Integer end; aDisabled = class(a) d: String //plus this way you can use long strings end;
This way, you can get some support from the IDE code editor even during development. More useful, however, is that it will be much easier to modify and maintain later.
However, if you need to quickly switch the values ββof recording variables at runtime, @David Heffernan variant , using properties and checking the runtime is more reasonable.
source share