As it often happens, I found the answer to this question while I was typing it up. However, I think it'll be valuable for others so I will post it nonetheless.
I got the syntax for pattern matching in this answer: https://stackoverflow.com/a/21929342/451847
It seems that the 'proper' way of pattern matching is to prefix the type you want to test for with a \
.
So, the code above becomes:
...
}else if(\object() := t){
return "object";
}else if(\float() := t){
return "float";
}else if(\double() := t){
return "double";
...
The non-\
syntax works for most of the cases but I think int()
and void()
have a different definition.