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

type stability of map and empty arrays #18314

Closed
mhauru opened this issue Sep 1, 2016 · 3 comments
Closed

type stability of map and empty arrays #18314

mhauru opened this issue Sep 1, 2016 · 3 comments

Comments

@mhauru
Copy link
Contributor

mhauru commented Sep 1, 2016

I find it desirable that in map(f, T[]), if f is type stable on T, then map would return an empty array of the correct type. At the moment it returns an empty array of type T.

I ran into this when trying to do roughly this:

function f(x::Vector)
    y = map(symbol, x)
    return f(y)
end

function f(x::Vector{Symbol})
    # Do fun.
end
@cstjean
Copy link
Contributor

cstjean commented Sep 1, 2016

#7258 It's not a simple issue.

@TotalVerb
Copy link
Contributor

TotalVerb commented Sep 1, 2016

For what it's worth, this problem should be gone in v0.5, to be released soon. The inferred type is used in the empty case.

julia> map(Symbol, [])
0-element Array{Symbol,1}

@mhauru mhauru closed this as completed Sep 2, 2016
@mhauru
Copy link
Contributor Author

mhauru commented Sep 2, 2016

That's indeed worth quite a lot.

Also, I found a duplicate: #12513

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