-
-
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
Mapping empty Arrays #10307
Comments
I think this is already covered by #210/#1864/ #10269. Without knowing what type the function returns, we can't get the proper return type for an empty array. But even if we could do that, type inference would also have to know about the return type to solve the performance issue. Parametric function types should solve all of this. |
I believe not all functions will be parametric and hence |
For those particular conversion functions, e.g. |
I think making it return Any[] would be reasonable then |
|
I feel like we've already been here: |
I think I'm concerned about it, but I also don't see what else can be done. |
But won't the same problem reappear if you try to call |
The counterpoint to @nalimilan's example is |
Yeah, the eternal covariance vs. contravariance dilemma... |
When there is no "one right answer", you have to make these decisions based on expected use in each case. You hardly ever see code that even mutates, let alone grows, the result of a If arbitrarily mutating the result of |
typeof(float(String[])) is Array{String,1}. This can cause performance issues.
typeof(map(float, String[])) behaves the same.
Even worse, runtime errors if someone reads numbers from a line and later tries to push! something to them - if the line was empty, you get an ERROR.
The text was updated successfully, but these errors were encountered: