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

Tuple{} vs tuple() in Generated Function Vararg type #12783

Closed
simonster opened this issue Aug 24, 2015 · 7 comments
Closed

Tuple{} vs tuple() in Generated Function Vararg type #12783

simonster opened this issue Aug 24, 2015 · 7 comments
Assignees
Labels
breaking This change will break code
Milestone

Comments

@simonster
Copy link
Member

Consider:

julia> @generated function f(x...)
           println("x in generated function: ", x)
           :(println("typeof(x) in function that is run: ", typeof(x)))
       end;

julia> f(1, 2)
x in generated function: (Int64,Int64)
typeof(x) in function that is run: Tuple{Int64,Int64}

As you can see, x in the generated function is not actually the type of x in the method that is run. I would have expected that both would be Tuple{Int64,Int64}.

@simonster simonster added the breaking This change will break code label Aug 24, 2015
@mbauman
Copy link
Member

mbauman commented Aug 24, 2015

See comments at #10380 (comment) and following. If we were to change this, I think we need a Tuple API first.

Edit to add: Another reason to do this is that it would be nice to use Tuple subtype relationships in some cases (like here: base/abstractarray.jl#L502 )

@vtjnash vtjnash changed the title Generated function vararg behavior is a bit weird Tuple{} vs tuple() in Generated Function Vararg type Aug 24, 2015
@JeffBezanson
Copy link
Member

Yeah, on further reflection I think this is actually better. If tuple types are easier to access it makes even more sense.

@quinnj
Copy link
Member

quinnj commented May 28, 2017

Giving a bump here as I recently ran into wanting tuple types being easier to work w/.

@JeffBezanson
Copy link
Member

Here's one problem. Given

@generated f(x...) = # something

For the call f(Int, Int) you currently get x = (Type{Int}, Type{Int}) when the generator is called. However, at run time typeof(x) is going to be Tuple{DataType, DataType}, so binding x to that at code generation time loses information.

@StefanKarpinski
Copy link
Member

We may want to consider generated functions to be an unstable feature even post 1.0.

@JeffBezanson JeffBezanson added the triage This should be discussed on a triage call label Sep 29, 2017
@JeffBezanson
Copy link
Member

I propose closing this.

@JeffBezanson JeffBezanson removed the triage This should be discussed on a triage call label Oct 5, 2017
@JeffBezanson
Copy link
Member

Passing a tuple here doesn't bother us enough to be worth changing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking This change will break code
Projects
None yet
Development

No branches or pull requests

6 participants