Declarations vs. assignments
Oh dear, another keyword. I’m not doing very well at this “as little syntax as possible” thing. But I don’t really know what else to do about this: I don’t think SSA would be a very good fit.
My new nemesis: var. Other candidates like def or val haven’t been ruled out yet, though, except that they have the wrong connotations to me — defs are re-evaluated every time they are used, and vals are sort of semi-constant1.So that’s why I’m thinking var.
Like I said in Reserved words so far (which I’ll have to update now…), there really needs to be something like this to distinguish between variables existing in nested scopes. We’re doing a similar thing to JavaScript here, namely, updating the non-local variable, if any, unless a new one is declared with var. What we are not doing which JavaScript does, of course, is implicitly creating a global var if no such binding is found anywhere; instead, we’ll have a compile failure.
var is not needed for function parameters, of course; that would be silly. That includes anonymous functions, which never overwrite the outer scope with their loop counters or anything unpleasant like that.
-
Specifically,
finalin Scala. ↩
