r.amazing();
But that function is defined as taking a Bool. What is this call supposed to do?I’m also curious how you plan to implement match type. How would this work if you give it eg a char ? Will the compiler know what the type is and pick the right clause. I don’t really see a way to do it by inspecting the data at runtime so maybe the pointer would have to have runtime type information attached to it, but you would then need to transform that info when dereferencing the pointer as this info can’t live in memory next to the pointed-at objects if you want C compatibility.
I also can’t really tell what match type is for from your example. Are you intending to have inheritance and then using match type as a kind of ad-hoc polymorphism (eg is my Animal a Dog or is it a Cat?), or some sort of weird template-like thing, or something else entirely?
If you allow subtyping then does “func(Dog->Int)” successfully match something of type “func(Animal->Int)”?
Or is it supposed to allow for some kind of ad-hoc polymorphism like:
func foo(x) string {
match type(x) {
char** : return “an array of strings”
int : return “a number”
default : return “not sure”
}
}
And this gets transformed into something like: func foo(Type x_t, x_t x) string {
match(x_t) {
pointer_t(pointer_t(char_t)) : return ...
...
}
}