3 ms·
The type of Tea is 'type', not Tea. Unlike in C++, types are values in Zig, so it would be like calling Tea::drink() in C++. You need an instance of Tea in ord
by stefncb 4y ago
The type of Tea is 'type', not Tea. Unlike in C++, types are values in Zig, so it would be like calling Tea::drink() in C++.
You need an instance of Tea in order to call drink, and if it's const it won't compile because drink takes type *Tea, not *const Tea.
- quietbritishjim 4y agoInteresting, thanks. In that case, what if `Tea` was not const? Could I assign a different type to it? What would the static type of an instance of Tea be, if its runtime value could be two incompatible types?
- stefncb 4y ago1. You can use a type variable as a normal one, as long as you do it at compile time (a variable of type type is required to be comptime). You can use a TypeInfo at runtime if you like though. 2. The type system is deep enough to describe the type of values, but not the type of types. That's what higher kinded types are for, and for better or for worse that's not part of zig. Also, type variables can only exist at compile time, so there is no runtime value.
- quietbritishjim 4y agothanks!