[J3] 21-120r2: Discussion on the feasibility of any future enhancement of Enumeration Type

John Reid John.Reid at stfc.ac.uk
Tue Mar 2 13:02:22 UTC 2021


Vipul,

I have an outstanding problem with your idea. On the one hand you want

Type safety: Users don't get a constant from the wrong collection by 
accident

and on the other hand you want

Convenience: Users can reference the constant without extra syntax

Here are some suggestions for rules:

For a binary operation with both operands of the type and no matching 
defined operation, both are regarded as of the underlying type.

For a binary operation with one operand of the type and no matching 
defined operation, it alone is regarded as of the underlying type (don't 
convert two different enums to their underlying types).

For an assignment with both variable and expr of the type and no 
matching defined assignment, both are regarded as of the underlying type.

For a function reference with one or more actual arguments of the type 
and no generic resolution, just the arguments of this type are regarded 
as of the underlying type.

Apart from this, I think explicit type conversion should be required to 
alert the user to the danger.

What do you think?

Cheers,

John.


More information about the J3 mailing list