-
-
Notifications
You must be signed in to change notification settings - Fork 399
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
Wrap indices used in macros in let/local #584
Conversation
@@ -130,6 +137,26 @@ end | |||
|
|||
getloopedcode(c, code, condition, idxvars, idxsets, idxpairs, sym) = code | |||
|
|||
localvar(x::Expr) = Expr(:block, _localvar(x)...) | |||
_localvar(x::Symbol) = :(local $(esc(x))) | |||
function _localvar(x::Expr) |
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.
What does this do?
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.
Handles this gross case from the tests:
@defVar(m, tri_3[(i,j)=[(i,i+2) for i in 1:5],k=i:j])
and gives you
local i
local j
for (i,j) = [(i,i + 2) for i = 1:5]
...
end
Not seeing any performance regressions. On master:
and this PR:
|
Could you compare with 0.3 just for sanity check? Also need lots of new tests here. |
end | ||
cnt = 4 | ||
for i in 5:8 | ||
@defVar(m, y[i=2:4,j=1:3] ≤ i) |
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.
Check the upper bounds on y
?
f825be7
to
108b133
Compare
surrounding scope (#582)
108b133
to
f35e9d4
Compare
if t.head == :tuple | ||
append!(args, map(_localvar, t.args)) | ||
else | ||
error("Internal error; please file an issue") |
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.
How? Maybe add the URL?
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.
Will add that separately.
Wrap indices used in macros in let/local
I'm a bit worried that this will subtly break something. I think it needs a bit of time to settle in. Not sure if it should go into 0.10.2. |
Agreed, since this is technically breaking. |
Should maybe get a NEWS entry then |
Ref #582, this seems like a reasonable change in that it makes JuMP behave more like a DSL. Haven't added v0.3 support yet, nor done perf testing to see if this slows things down.