-
-
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
fix #9503 plus another proposal on comparison and iteration syntax #15524
Conversation
Breaks-JuMP warning! And probably any other package that has macros that deal with comparisons. |
While working on https://github.com/invenia/JuliaFormat.jl I discovered the comparison special case and it surprised me. What was/is the reasoning/use for it? |
We can handle this breakage, don't let it hold you up. |
Yes, everything in this PR is breaking. I think the new version is easier, since comparison chains |
(t (peek-token s))) | ||
(if (not (or (closing-token? t) (newline? t))) | ||
;; should be: (error "invalid iteration specification") | ||
(syntax-deprecation s (string "for " (deparse `(= ,lhs ,rhs)) " " t) |
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.
Any test for the deprecated syntax?
b61a557
to
98fbc7d
Compare
I'm going to leave the for loop separator issue out of this; belongs in a separate change I think. |
98fbc7d
to
8d76566
Compare
fix #9503 plus another proposal on comparison and iteration syntax
@timholy is any change needed in Lines 371 to 376 in 0d5f541
|
The first commit is a straightforward fix for #9503, always parsing
a<:b
as an expression with head<:
.This change inspired the second commit, which does two related things. First, 2-argument comparisons are parsed as calls. Previously, we parsed
a<b
as(comparison a < b)
, which I think is a quasi-bug since this can be handled as a simple function call and doesn't need chained comparison treatment.That led to looking at iteration syntax, which depends on the parsing of
a in b
. One problem here is that=
andin
have different precedence, so depending on which you used you could get different syntax errors. For examplefor i = a&&b
parses butfor i in a&&b
is a syntax error. I fixed that by usingin
precedence in all cases.Next I decided that it's not so good to allow
for i = 1:n f(i) end
, so I deprecated that. Allowing space as an implicit separator here is one thing that prevents generalizingin
syntax to other function names.