-
-
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
CartesianIndex
cannot iterate/splat
#21148
Comments
The absence is deliberate, since splatting usually has a huge performance penalty without Of course, this is something that could be reconsidered. |
The lack of iteration just seemed unusual, is all. |
I agree. If splatting weren't a major performance trap for the unwary, I'd have no reservations in saying that we should support splatting. |
nL = [400, 200]; ly = nL[2]-1
obs = [100, 100]; obsRadius = 20
map((d,x,y)->if d==2; 0 else 0.04*(1.0+1e-4*sin(y/ly*2*pi)) end, CartesianRange(tuple(2, nL...))) That one can't work in 0.6 since there is no automatic splatting. Though, since that behaviour changes in 0.7 (automatic splatting into arguments) I've been curious wether it could be reconsidered to allow in such case that it's splatted into the arguments of the anonymous function. |
BTW, you can also do Some thoughts regarding the performance of splatting So better constant propagation could help. That would require keeping track of partially const tuples: Another approach I've been pondering is to parse Alternatively, one could introduce a new function, say Or we change the iteration protocol slightly to first do Nothing of the above strikes me as the obvious way forward. |
For what it's worth:
While I initially agreed with this sentiment, I have since changed my view on this. A |
We've since doubled down on this view. I think we can close this issue as resolved/won't change. |
It seems unusual to me that the indexable
CartesianIndex
cannot also iterate (or splat).For context, I had tried this for creating an expression in a generated function by splatting out the Cartesian indices (so run-time performance of iteration vs. indexing isn't an issue). The (or rather, my) workaround is significantly less elegant.
The text was updated successfully, but these errors were encountered: