3 ms·
The justification for function-scope instead of block-scope is that only the former really works if you have implicit variable declarations. In turn, implicit
by pansa2 6y ago
The justification for function-scope instead of block-scope is that only the former really works if you have implicit variable declarations.
In turn, implicit variable declarations (using the same syntax for initialisation and assignment) are a reasonable choice for a language that aimed to be “executable pseudocode” and that supports mixing initialisation and assignment in a single statement (e.g. `a, b, self.c = foo()`).
- Blikkentrekker 6y agoIt could easily be written as `var a, var b, self.c = foo()`. Having the same syntax for initialization and assignment is quite quæstionable.
- pansa2 6y agoThat’s not a bad suggestion, but it’s quite verbose (it would require declaring multiple variables as `var x, var y, var z` instead of `var x, y, z`).
- Blikkentrekker 6y agoThat could easily be `var (x, y, z) =`, which is similar to what many languages use.