On Sun, 16 Jan 2022, Ryan Joseph via fpc-pascal wrote:



On Jan 16, 2022, at 9:21 AM, Ryan Joseph <generic...@gmail.com> wrote:

There is a possibility for using "as" operator also though....

oops I mean "is" operator. Not sure if these are technically different from 
ClassType = ClassType though...

They are.

No "is", because then the order of the label will start to matter, and that 
runs contrary
to the case statement's intent.

if you use 'is' then

case A of
  TPersistent: Writeln('TPersistent');
  TComponent : Writeln('TComponent');
end;

would always stop at TPersistent for every TComponent descendent, and that
is not what you want.

So to preserve the semantics of 'case' (order of labels does not matter), it must be an exact match.

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

Reply via email to