Phil Nelson wrote:
type TComparisonResult=(Less value -1, Equals, Greater, Strange value 10);
i.e. Ord(Less)=-1, Ord(Equals)=0, Ord(Greater)=1, Ord(Strange)=10.
Another problem ... it will make pred() and succ() harder if they must do succ(Greater) => Strange and pred(Strange) => Greater. I think setting the initial value would be reasonable, but not allowing a jump in the values.
Only allowing to set the initial offset would make this kind of fetaure useless. Implementing succ and pred functions using a simple table will not cause much trouble.
Imagine this (for me very actual) problem:
Type assembler_instructions = ( add_x, sub_y, mul_a_x) ; (* course more complex*) register_type = ( ax, bx, dx, bc, de, hl );
objectfile = record ai : assembler_instruction; p1, p2 : register_type; end;
(* using some ada-style for making the example *)
for assembler_instructions use ( add_x => 27, sub_y => 37, mul_a_x => 127);
for register_type use ( ax => 12, bx => 22, dx => 32, bc => 01, de => 17, hl => 33);
The ord-function will, assuming you order the register-names in a simple index only cause code to extract the real ord number from a table, i.e.
ord_values : array (.enumeration_type.) of integer; (* the array keeping the values*)
Just suggesting :)
/Jakob :)
mailto:Jakob.Heinemann@ericsson.com Ericsson Saab Avionics AB Linköping +46 13 284249