1.2.70 $SCOPEDENUMS Control use of scoped enumeration types

The boolean $SCOPEDENUMS directive controls how enumeration type values are inserted in the symbol tables. The enumeration values are always inserted in a scoped manner.

In its default state (OFF) the enumeration values are additionally inserted directly in the symbol table of the current scope. That means that the following 2 assignments are valid:

{$SCOPEDENUMS OFF}  
Type  
  TMyEnum = (one,two,three);  
 
Var  
  A : TMyEnum;  
 
begin  
  A:=one;  
  A:=TMyEnum.one;  
end.

If the directive is set to ON then the enumeration values are not inserted in the global scope.

This means the assignment must be made as follows:

{$SCOPEDENUMS ON}  
Type  
  TMyEnum = (one,two,three);  
 
Var  
  A : TMyEnum;  
 
begin  
  A:=TMyEnum.one;  
  // The following will give an error  
  // A:=one;  
end.

i.e. in the ON state of the directive, the value must always be prefixed with the type name.