Crell / enum-comparison

A comparison of enumerations and similar features in different languages
82 stars 7 forks source link

Are constants allowed? #21

Closed bwoebi closed 3 years ago

bwoebi commented 4 years ago

We permit static methods … do we also permit constants (on enum decls, anyway not on cases; should be stated explicitly in the RFC though)? Should be symmetrical, but not sure about possible confusions. And in the same thought train, static properties?

iluuu1994 commented 4 years ago

I'm not sure. Allowing them later on would be much easier than removing them.

Crell commented 4 years ago

I'm inclined to say no. The purpose of enums is not to be classes per se; that's an implementation detail. Their purpose is to define types that are themselves fully defining their meaning by virtue of being types. The only data of any kind that should be needed is for ADTs/Associated Values. Beyond that, the type definition itself is supposed to be where the design decisions lives.

I don't know what you'd even do with constants or static properties on the EnumType.

bwoebi commented 4 years ago

If you have static methods… why wouldn't you have static properties?

On constants, their use case could be defining mappings between enum and primitive values.

iluuu1994 commented 3 years ago

We've decided against constants. I'm not yet totally sure about static properties but I'm also tending towards no. I'll close this issue for now.