joshradin / Jodin-Java

An Object Oriented Extension to the C Language
0 stars 1 forks source link

Remaining C Parity Features: Enums and Unions #19

Open joshradin opened 4 years ago

joshradin commented 4 years ago

Enums and Unions are currently unsupported in the language completely. In order to make the language more type safe, unions will likely be removed. Enums could be implemented in three ways.

C - style

Enums are not namespaced in any way, and are just there to give names to sequential numbers. This is a very simplistic implementation and is not very useful.

Namespaced Enums

Enums members can only accessed using the name of the Enum type. Additionally, enums of different types can't be equated.

Namespaced Enum Objects

Enum members are objects. The enum declaration could include constructors that the members must all call in order to be valid. In addition, enum declarations could have methods, and implement traits.