tomhrr / dale

Lisp-flavoured C
BSD 3-Clause "New" or "Revised" License
1.03k stars 48 forks source link

Why enums in language core? Unifying namespaces and enums? #82

Closed porky11 closed 8 years ago

porky11 commented 8 years ago

, Namespaces and enums seem very similar. Enums are like namespaces that only define values of a single type. (some-enum …) may expand to (using-namespace some-enum …) This would minimize the core language, but using these enum-namespaces as types would be a new problem. They could work similar to Rust's enums, which can also take structs as parameters.

tomhrr commented 8 years ago

On Wed, Sep 07, 2016 at 10:03:21AM -0700, Fabio Krapohl wrote:

, Namespaces and enums seem very similar. Enums are like namespaces that only define values of a single type. (some-enum …) may expand to (using-namespace some-enum …) This would minimize the core language, but using these enum-namespaces as types would be a new problem. They could work similar to Rust's enums, which can also take structs as parameters.

The namespace-like wrapping of enum instances ("(some-enum a), (some-enum b)") is now unnecessary, since const variables are defined for each instance. However, you are right that there is no real need anymore for enums to be implemented in the core. They are now implemented in the enum module.

The sum type behaviour of Rust's enums is supported (to an extent) by way of the variant module. I think these should remain as separate pieces of functionality, rather than being merged.