El 11/03/2020 a las 16:37, wkitt...@windstream.net escribió:
On 3/11/20 11:35 AM, fredvs via fpc-pascal wrote:
f (kind in tabulatorkindty) then

Yes, I like it!

But, sadly, the compiler no.

"Error: Operator is not overloaded"...


that's weird... i thought that construct was standard for arrays and similar... hummm...

You should define

type Set_Of_tabulatorkindty= set of  tabulatorkindty;
const
    AlltabValues:Set_Of_tabulatorkindty=[low(tabulatorkindty)..high(tabulatorkindty)];
then

if (kind in AlltabValues) then

is right

Nevertheless, "kind" is of type "tabulatorkindty", so it is always in the range. The only case when it is not in the range is if it is uninitialized. And in Pascal, fields of objects are initialized (nil, or zero, or empty string etc), but uninitilized variables don't contain uninitialized values, contain garbage, dangerous garbage. So, in pascal,  you don't test if a variable contains an uninitiliazed value, you initialize it before referring the variable.

And before assigning a value, you verify it is in the range.

--
Saludos

Santiago A.

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

Reply via email to