Skip to content
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

In the debugger, if blocks DO introduce new scope. #67

Open
mikewojnowicz opened this issue Feb 4, 2015 · 1 comment
Open

In the debugger, if blocks DO introduce new scope. #67

mikewojnowicz opened this issue Feb 4, 2015 · 1 comment

Comments

@mikewojnowicz
Copy link

According to the Julia performance manual, if blocks and begin blocks do not introduce new scope. However, the Debug package alters this fact.

When running testfunction() outside the debugger, the object "value" exists for both iterations of k=1:2.
However, when running testfunction() inside the debugger, the object "value" only exists for the first iteration. Then, on the second iteration, we get: ERROR: value not defined.

I realize the fix is quite simple, but for whatever it's worth, I found this aspect of the debugger to be quite confusing to me as a new Julian (coming from R and MATLAB).

using Debug

@debug function testfunction()
for k=1:2
if k==1
value=k
end
println(value)
end
end

testfunction()

@toivoh
Copy link
Owner

toivoh commented Mar 8, 2015

I started to look into this, but it's a pretty perplexing error. @debug emits an instrumented version of code it gets, and the semantics should really be the same as for the original code. I hope I can get some more time to look into it.
For now, things seem to work fine if you introduce the value variable just before the for loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants