I’ll try to give an example of what I’m trying to achieve:
const Pet = enum {
Cat, // 0
CatBreed1,
CatBreed2,
CatBreed2Sub1,
CatBreed2Sub2,
Dog,
DogBreed1,
DogBreed2, // 7
};
// A namespaced enum?
const Pet = enum {
Cat = enum { // 0
Breed1, // 1
Breed2 = enum { // 2
Sub1, // 3
Sub2, // 4
},
},
Dog, // 5
DogBreed1, // 6
DogBreed2, // 7
};
// Pet.Cat = 0
// Pet.Cat.Breed2 = 2
// Pet.Cat.Breed2.Sub2 = 4
// Why? Suppose that nested enums could work as follows:
const cat = Pet; // cat.is(Pet) -- true
const cat = Pet.Cat; // cat.is(Pet), cat.is(Pet.Cat) -- all true
const cat = Pet.Cat.Breed1; // cat.is(Pet), cat.is(Pet.Cat), cat.is(Pet.Cat.Breed1) -- all true
Basically, I need a tree of types, where types can be “specialized” and be compared against their generic ascendants. Not sure how to think about it (organize) in terms of Zig.