-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Request for generic alias #2803
Comments
I think it's possible and shouldn't be that hard to do. |
Bump My use-case isn't for long names, but for something like:
This mimic Functional Programming's Variants:
|
+1, by the way, it's the 6th most voted feature in the Crystal issues, is there any timeline when it's planned to be implemented? |
Somewhere it was mentioned that #5155 is a blocker for this, but I never understand why. |
It's probably not. |
Let's sort out some of the formalities then. Should aliases that don't use all of their generic parameters be allowed?
Can generic aliases be used to reopen types? (probably not, even when the type variables match exactly)
What happens when a generic alias instance does not resolve to a generic instance?
|
I don't think so. What purpose would that have?
I actually didn't know you could do that with non-generic aliases 🤔 Again, what would be the purpose?
I think that should be disallowed. I'd keep it as minimal as possible. We can allow advanced features later if a use case shows up. |
Bump, ran into a use case where this would have been perfect. |
Not sure what's the solution for this ? Or we must keep boilerplate everwhere, like Is something like this possible ? |
@revskill10 I'm not sure I follow what you mean by "boilerplate everywhere". ref: https://crystal-lang.org/reference/syntax_and_semantics/type_grammar.html#nilable |
In Crystal, we can alias a type like this:
And all
Foo
will be replaced withSomeGeneric(Int32)
.But we cannot alias as a generic type like this:
Can Crystal support this syntax for a generic alias?
It will be useful to avoid writing long type name.
The text was updated successfully, but these errors were encountered: