Why predeclared variables?

Ah, OK, I see – I was a bit confused because your previous post said “‘letting this be’ and allowing vars to be declared anywhere … forces the JavaScript solution,” which looked to me like rejecting the idea of throwing a compiler error there.

So, making the var-ing of xx illegal (after use in the same scope, in that example in the assignment to yy [and its postln]) would be a “breaking change”, but not a terrible one

That’s a good point. I think the user impact will be essentially zero. FWIW the documentation is accurate – “[Variables] may be declared in any order” – but conventional wisdom in SC-land is that variables should be declared before use, and it would be difficult to find projects that rely on var yy = xx; var xx = 5.

In other words, the proposed change would render illegal programs that have rather non-intuitive semantics in the present SC implementation.

Agreed, with this and with the rest of the post.

Thanks –
hjh

1 Like