Random question: why aren't pointers or references regarded as an ordinal type? This would allow you to switch on objects including controls, for example

Random question: why aren't pointers or references regarded as an ordinal type? This would allow you to switch on objects including controls, for example,
case Sender of
radioOne : ...';
radioTwo : ...;
end;
Currently, using case on any reference or pointer gives the error, "E2001 Ordinal type required".

In Delphi, "Ordinal types are the predefined types Integer, Char, WideChar, Boolean, and declared enumerated types" (although this should perhaps say all integer types, since it includes ShortInt, Byte, NativeUInt, etc as well.) An ordinal type in general is "a data type with the property that its values can be counted. That is, the values can be put in a one-to-one correspondence with the positive integers." (From Wikipedia.)

The thing is, pointers seem to fit nicely into that classification. Is there a theoretical, language, or compiler reason I'm not aware of why a pointer is not regarded as ordinal?

Comments