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 when mapping an empty array #12513

Closed
m-legrand opened this issue Aug 8, 2015 · 4 comments
Closed

Type when mapping an empty array #12513

m-legrand opened this issue Aug 8, 2015 · 4 comments

Comments

@m-legrand
Copy link

Poking around with Julia, here is what I found :

capture d ecran 2015-08-07 a 18 10 44

My question is... why ? Let's assume you have a `fun : type1 -> type2` with which you want to map an `Array{type1,dim}`, for example in a function you are writing for a general purpose. Who in this world will want an output-type depending on the size of the input, having an `Array{type1,dim}` if it is empty and an `Array{type2,dim}` if not ? In most cases people will have to struggle a bit to find where are their issues from, then correct it with an ugly hack like `if isempty(A) ... else ... end`. And of course it can happen in any dimension...

capture d ecran 2015-08-07 a 18 35 24

@johnmyleswhite
Copy link
Member

You should read through some of the older issues. You'll find a lot of discussion of this topic.

@m-legrand
Copy link
Author

Well, indeed. The talks around it still don't convince me that this case is not ten times less intuitive than the opposite, though.
#10307

@carnaval
Copy link
Contributor

carnaval commented Aug 8, 2015

Indeed. And the current behavior is arguably the worst possible since it has no justification, is surprising and might even work in some cases.

The reason why this has not changed yet is that we still have not reached consensus on the other possible behaviors. The combination of 1) julia has dynamic semantic 2) homogeneous arrays 3) resizable arrays; makes this issue surprisingly deep. Feel free to jump in the discussion :-)

@carnaval
Copy link
Contributor

carnaval commented Aug 8, 2015

Ref also #7258 #11034 on the top of my mind

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