-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Macros type inference should support pointers #273
Comments
"All use cases" is never the goal here. It is understood that we will carve out a subset of macros for which we can infer a reasonable type and produce reasonable code. It is certainly useful to open issues such as this so that we better delineate what we can and cannot do, but for now I'm with leaving this unsupported. If it turns out we do need to support it, I'm not sure that the conclusion is that "HM type inference is not the right approach" immediately follows, however. Perhaps we just need to give the overloaded |
From https://en.cppreference.com/w/c/language/operator_arithmetic
Things like #include <stdio.h>
int main() {
printf("%f\n", 12.5f + 10L);
return 0;
} adding
I'd argue that both usages of addition (arithmetic types, and pointers) are valid and common. I we only support one, we should very loudly say that. |
I'm certainly in favour of documenting clearly what we do and don't support. Note that "common" isn't necessarily the right thing to be concerned about; "are they common as part of a library's public API" is the more important question (the answer might still very well be "yes", of course). @sheaf Do you think that there is any relatively low-hanging fruit here, ways in which we can generalize type inference to cover, or anticipate, some of these generalizations? |
Another problem is that |
In general, I think that HM-like inference is not the right approach for macros. That's C after all, where
"foo" + 1
is a type correct expression, which actually does something reasonable.prints
oo
. And forADVANCE
it's not right to inferNum a => a -> a -> a -> a
type. It doesn't include all use cases.The text was updated successfully, but these errors were encountered: