To be honest, I'm ok with Stefan's response. My problem was based on a mistake on my part (I didn't realise that I had $i declared outside of the loops; I thought I'd opened a new julia instance) and an expectation for C style looping rather than Python style (ie 'for' \equiv 'let').
Since Julia can expect more people from my C-based background, I would suggest that this be highlighted in the, rapidly evolving, manual. I would also argue for a devoted article on variable scope in the manual in the long run. I am quite comfortable with the decisions you've made in designing the language, but they are contrary to what we are used to from many other languages. And while the inability to write to a global variable from within a function in the absence of a global declaration is numerically very sound it leads to a whole new set of potential programming errors. David. On Sunday, 8 February 2015 10:27:41 UTC+1, Mauro wrote: > > > Even more commonly, I want to know (and use) the value of the iteration > > variable at the iteration that threw an error. Debugging errors in > loops > > would be more difficult without this ability. > > But that only works in the global scope in the REPL, right? So that is > a pretty limited use, and hopefully there will be a debugger available > soon. And it could be worked around with one additional line: > > for i=1:n > ii=i > do_something > end > > Another pro-argument: This change would mean that all the scope-blocks > which introduce a binding in their head (function, let, for) make it > local to the block. >
