Allow declaring constants
skx opened this issue · 1 comments
skx commented
Related to #19 we could move PI
, & E
, into the monkey-based init-file(s) if we had the ability to define constants, which couldn't be modified.
Something like:
const PI=3.1.4..
Instead of:
let PI=3.14..
This should be a simple matter of updating our environment.
skx commented
At this point we have a const
expression which works - but scoping is subtly broken. Consider this code:
let a = 333;
function foo() {
const a = 33;
puts("A:", a, "\n");
}
foo()
puts( "A:" , a, "\n");
The code outputs 333, 3333. This is because of the way we lookup the values of constants and variables separately. Instead the should do it once, following scoped-rules.