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

vararg tuple types not working when vararg not at last place #10770

Closed
mauro3 opened this issue Apr 8, 2015 · 5 comments
Closed

vararg tuple types not working when vararg not at last place #10770

mauro3 opened this issue Apr 8, 2015 · 5 comments

Comments

@mauro3
Copy link
Contributor

mauro3 commented Apr 8, 2015

This does not work:

julia> (Int,Int,Float64)<:(Int...,Float64)
ERROR: type: subtype: expected Type{T<:Top}, got (DataType,DataType)

however inside methods a tuple like that does seem to do something, at least when a Any... is involved:

julia> methods(f, (Any...,Int,IOBuffer))
1-element Array{Any,1}:
 f(a::Int64,b::Int64,c::Float64) at none:1

julia> methods(f, (Int...,Float64))
0-element Array{Any,1}

I'm not sure how it should work but probably not as above. Allowing several ... inside a type tuple could be useful. Related: #10380, #8974

@JeffBezanson
Copy link
Sponsor Member

This is absolutely not supported yet. It would be very useful, but extremely difficult. The weirdness with methods is kind of a syntax bug that will be fixed by #10380; after that it won't be possible to write that.

@timholy
Copy link
Sponsor Member

timholy commented Apr 8, 2015

By and large there is zero support for varargs anywhere except the last slot. Many of us have had times where it could have been useful, but having dug into the code that supports varargs I agree that it would represent an enormous increase in complexity.

I suspect that a good number of things we do with varargs now will be done with tuples in the future. See, for example, the discussion in #10691. So I don't think it's worth going to the effort to implement this, certainly not until we see how the tuple revamp works out.

@mauro3
Copy link
Contributor Author

mauro3 commented Apr 8, 2015

In that case, maybe throw an error on construction?

@JeffBezanson
Copy link
Sponsor Member

Yes, that's what will happen, because (Int..., ) will mean to splice Int into a tuple.

@JeffBezanson
Copy link
Sponsor Member

fixed by #10380

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

3 participants