
On 30/05/20 7:15 pm, Steven D'Aprano wrote:
Out of curiosity, which languages are you thinking of? I know Lua does that, I can't think of any others.
You've probably never seen the one I'm thinking of. It's a proprietary, vaguely VB-like language used for scripting a particular application. It doesn't work like Lua, but it does have scoping rules that can lead to some surprising results. I've been bitten by it treating something as global that I intended to be local, which has made me appreciate Python's approach to scoping. One particularly weird thing it does: if you don't declare a variable (it has optional declarations) it will *usually* infer it to be local if you assign to it. But if the first assignment is in a conditional branch of the code, it seems to get confused. If you do this: if something then x = 5 else x = 7 end if and later refer to x, it complains that x hasn't been defined. Go figure. -- Greg