-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Allow Tuples of Int/Symbol (and maybe more immutable things) as type parameters? #5102
Comments
I think that strings are a bad idea since they're only immutable by convention and it's a bit questionable when two strings are really "the same". Tuples of immutable a would be very powerful as this would effectively allow varargs parametric types. |
yeah strings seem a bit sketch to me as well; I also can't think of a situation off the top of my head where you couldn't just use symbols. My current use case is actually implementing mixed-radix numbers. I want every potential combination of bases (each of which is representable as a Tuple) to be it's own type and enforce that only two numbers with identical bases at each position can be added, subtracted, etc. I have no idea how difficult making the language support this would actually be though. |
You can already get this now by using a wrapper. See https://github.com/timholy/HDF5.jl/blob/master/src/plain.jl#L393-L394 for an example that should directly solve your problem. I definitely think we should allow tuples of integers as type parameters, it's weird that you need a wrapper at all. |
@timholy Thanks! Makes my design a lot cleaner. But yes would be better still to use the Tuple directly. |
Are there plans to allow user-defined immutable types as parameters? |
I came across a situation recently where this might be useful; I've also seen some discussion of allowing for more immutable things as type parameters (strings, for example) on the mailing list and I didn't see an issue for it; someone feel free to close if there is already and I've just missed it. I'm not sure it makes sense to go as far as to allow any immutable, but I'm curious how other people feel about being a bit more permissive here.
The text was updated successfully, but these errors were encountered: