Description
After reading Herb's P0707, I just wanted to ask which one of the metaclass examples provided in the paper are planned for cpp2.
Herb has already mentioned in #277 that he has planned for safe_union
, flag_enum
and regular enum
. I guess that interface
would also be provided andfinal
probably won't be there as we can mark methods as final
and that'll do enough to not have the metaclass (or shouldn't final
be a specifier for the class definition instead of a metaclass itself?).
Also, will those metaclasses be in a some namespace?
Next up, the suggestion. I was originally going to suggest 3 language built-in (for some day that cpp2 gets its own compiler), one of those was same as safe_union
that is planned but with only one difference. So, instead of having 2 different safe and unsafe types, maybe there could be only one type that is safe by default but using a supress
block, we can do unsafe operations on it. Is that feasible? If yes, maybe it could be considered.
Next up, we can have a language inbuilt tuple
which, like safe_union
a cpp2 version of standard library type. We can name the members of this tuple
and it may serve as a replacement for both std::tuple
and C-like structs (since there is no need of classes or struct, we have cpp2's type
).
Third one is a language built in array, current std::array
is just a wrapper class around C-array and since cpp2 doesn't have to worry about C, we can have our own better behaved type like with bounds checking and a supress
block to turn off bounds checking (not just specific to this type but for others too). Simple arrays could default to this new type instead of a C - array and string literals could just default to string literals can default this new type of char
instead of const char*, a type which has no knowledge of size of string stored in it.
Basically, I'm asking for a std::array
but in core language.
The reason for third one is about having to move away from std::initializer_list, inbuilt language arrays would be a simple replacement to those (i guess? pls guide me)