Case..of with record type
Issue #66
wontfix
Can we use case..of with record type structure in dwscript (crossplatform/sms)?
type
TEmployee = record
case Salaried: Boolean of
True: (AnnualSalary: float);
False: (HourlyWage: float);
end;
// If this person is paid by the hour
Person.Salaried := False;
Person.HourlyWage := 20.00;
// If this person is paid an annual salary instead
Person.Salaried := True;
Person.AnnualSalary := 80000.00;
Comments (2)
-
repo owner -
repo owner - changed status to wontfix
- Log in to comment
Union records are not supported, in part because it would be very inefficient to emulate the binary mapping, and people using union usually do that for efficiency or low-level purposes.
Also in Delphi, neither the compiler nor the runtime enforce anything wrt to that "case".
In case where you do not have any complex mappings between the alternatives (like in your TEmployee), the declaration is thus equivalent to
ie. it is not a very useful type.