-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Comments
You should read through some of the older issues. You'll find a lot of discussion of this topic. |
Well, indeed. The talks around it still don't convince me that this case is not ten times less intuitive than the opposite, though. |
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 :-) |
Poking around with Julia, here is what I found :
![capture d ecran 2015-08-07 a 18 10 44](https://cloud.githubusercontent.com/assets/9072763/9148428/05284d7c-3d30-11e5-9f77-714c190deab6.png)
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...The text was updated successfully, but these errors were encountered: