-
Notifications
You must be signed in to change notification settings - Fork 109
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
Explicit generic function arguments #724
Comments
Teal does bidirectional type inference to try to avoid the need for this. In your example above, doing Do you have a more complex example where that doesn't work and the explicit generic function argument would still be necessary? I've been trying to see how far we can go without adding more syntax for function calls. |
So I went back to the case that prompted this request, and found that I was able to avoid the need for an explicit generic by adding more locals with explicit types. There might be some cases where this workaround isn't sufficient but I can't find it at the moment. |
I honestly don't see it as a workaround, since it amounts to the same number of annotations. I understand that one gets the feeling that ideally no variables should need to be annotated, but if anything, I find that not needing a new (pseudo-?)operator is a cleaner approach, language-wise. Explicit variable annotations and bidirectional inference do a lot of heavy lifting to resolve the types of things like literal tables (e.g. |
I think this could be useful in situations where the type is abstract (mainly interfaces) |
Sometimes, the type that is used by a generic function is not passed in implicitly by the arguments. These situations would benefit from having a way to explicitly tell the teal compiler what type should be used for a given generic argument.
For eg:
local foo = get_foo::<integer>()
This was previously mentioned as something to consider here but couldn't find an issue for it (if I missed this please close)
The text was updated successfully, but these errors were encountered: