-
-
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
make indexing expressions participate in dot syntax fusion #22858
Comments
Ref #19169 |
I would tend to prefer |
OK, I guess this is just a parser issue then. I can allow parsing |
Update: already parses, so just needs a case in the broadcast lowering code. |
It'll take quite a bit more than that, particularly in the logical indexing case like Stefan proposed in his example. The naive broadcast will just repeatedly pass a true or false index to the array. See my comment at #19169 (comment). |
Yeah, I just realized that and was about to post again. |
Writing this as |
|
Since the julia> v.[p.(v)]
ERROR: syntax: invalid syntax v.[p.((v,))] |
Now that I've recently thought through this, I figured I'd leave a note for posterity (and future me) on the difficulties here: An expression like
Logical indexing is really the worst case here. But there are other problems. Were we to do this, we'd only be able to support arrays of integer indices or we'd have to disable fusion from propagating inside the |
Nice writeup. Seems like the best course of action is to leave this as an error until we can handle it. |
Latest thoughts: In order to get around the difficulties I enumerated in my last post, I had been thinking I'd like to define
where Here's the unfortunate part: |
Sorry, closed it by github-mobile-interface accident. |
Consider an expression like
v[p.(v)] .*= 2
wherep
is a predicate (i.e. returns a boolean). Currently Julia's semantics are thatp.(v)
is constructed and then used to index intov
. However, the optimal implementation of this would to loop throughv
, testing each elementx in v
to see ifp(x)
is true and then multiplying it by 2 if that's the case. While it might be possible for a compiler to optimize the current semantics to this behavior in some circumstances, arguably, the dotted application ofp
in the indexing expression should participate in dot fusion of the whole expression, and this expression should simply mean the optimal implementation. Marking as 1.0 since if we're going to change the semantics of this expression, we should do so before then.The text was updated successfully, but these errors were encountered: