-
-
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
parse more dot operators, parse .= with assignment precedence #17393
Conversation
(I don't think we should document the new operators, yet, because we don't really want people to start assigning methods to them in 0.5 ... since in 0.6 the |
As far as I can tell, no existing packages use |
👍 |
It seems like we could allow |
Rebased and added |
@JeffBezanson, I'm bugged by However, the |
We could handle that by rejecting |
Or maybe we should just allow unary operators to be dotted, and allow This seems more consistent, but maybe it requires special handling in the parser to accept a unary |
(It seems like |
Okay, I took Jeff's suggestion and reject With unary operators the need for a dot prefix is somewhat less, because you can always write |
Seems like the libgit2 Travis test failure must be unrelated? |
Rebased and added NEWS. |
Should this have any parsing tests? |
I think having I can currently do |
@tkelman, added some tests. |
@andyferris, I don't think it should be that hard to implement more dotted unary operators, it is just that we are so close to the 0.5 release that I don't want to dig deep into the parser right now. |
Okay to merge? |
lgtm but I'm the wrong person to review the scheme code |
@JeffBezanson, looks like it's up to you to hit the "merge" button? |
@JeffBezanson is on vacation, so I'd recommend merging if you're happy with it and we can do a post-merge review when he gets back. |
lgtm. do these deparse (print) correctly? (also, there's now a trivial merge conflict in test/core, so needs a rebase) |
@@ -4462,3 +4462,11 @@ end | |||
f17147(::Tuple) = 1 | |||
f17147{N}(::Vararg{Tuple,N}) = 2 | |||
@test f17147((), ()) == 2 | |||
|
|||
# PR #17393 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put this in test/parse
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
@vtjnash, yes, the new dotted binary operators print fine. The assignment syntax |
Oooh, this is cool. Any thoughts here on decoupling the precedence of |
one note out of this is that we could deprecate elementwise |
Did this PR break the following? I haven't bisected but it seems like the julia> Base.|>(a, b) = a+b
ERROR: syntax: ">(a,b)" is not a valid function argument name
in eval(::Module, ::Any) at ./boot.jl:234
in macro expansion at ./REPL.jl:92 [inlined]
in (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:46 (found from Gtk.jl stopped parsing): |
The dot operators are now parsed, but the don't do anything different from 0.4 in this PR. Deprecations will have to wait until 0.6 when dot operators are sugar for a broadcast. |
Ok, I guess something else made that syntax fail to parse because it worked in 0.4 and it is currently failing. That fact that the error message says that |
@KristofferC, sorry, I was replying to @tkelman. Probably this PR broke |
parsing of these was changed on JuliaLang/julia#17393 ref http://pkg.julialang.org/detail/IntervalConstraintProgramming.html
the parsing here was changed in JuliaLang/julia#17393
Also broke IntervalConstraintProgramming and LibExpat |
parsing of these was changed on JuliaLang/julia#17393 ref http://pkg.julialang.org/detail/IntervalConstraintProgramming.html
…ang#17393) * parse more dot operators for JuliaLang#16285, parse .= with assignment precedence * include .|= and .&= in syntactic-operators list * reject .! operator * NEWS for new operators * tests * move tests to parse.jl
For 0.6, the plan in #16285 is to have
a .+ b
etcetera automatically correspond tobroadcast(+, a, b)
, and be fused with other "dot calls". Also, we are planning to havex .= ...
etcetera turn intobroadcast!
for in-place fused loops.As a first step towards that goal, this PR:
.=
to be assignment-like, rather than comparison-like.$
and||
. (Some of these could be allowed, but I wanted to be conservative to start with).I'd ideally like to get this merged in 0.5. The reason is that, once 0.6 rolls around, we will want a
@compat
macro to make some of #16285's vectorized syntax work (albeit suboptimally) in 0.5, and it will be hard to do that unless the operators parse.