This program below crashes because the value 12 is not in the enum. I was 
curious though, how does it know this? Does it have to do a linear search 
through the enum to find the value? I know "succ" fails at compile time because 
the enum has assignments but how this works at runtime is another question.

type
  Fruit = (apple = 10, 
           banana, 
           pear = 20,
           citrus);
var
  f: Fruit;
  i: Integer;
begin
  i := 12;
  f := Fruit(i);
  writeln(f);
end;

Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to