Skip to content
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

Closed
porterjamesj opened this issue Dec 11, 2013 · 5 comments

Comments

@porterjamesj
Copy link
Contributor

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.

@StefanKarpinski
Copy link
Sponsor Member

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.

@porterjamesj
Copy link
Contributor Author

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.

@timholy
Copy link
Sponsor Member

timholy commented Dec 11, 2013

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.

@porterjamesj
Copy link
Contributor Author

@timholy Thanks! Makes my design a lot cleaner. But yes would be better still to use the Tuple directly.

@quinnj
Copy link
Member

quinnj commented Jan 23, 2014

Are there plans to allow user-defined immutable types as parameters?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants