ulox icon indicating copy to clipboard operation
ulox copied to clipboard

Determine value of consts

Open stevehalliwell opened this issue 3 years ago • 3 comments

There is presently no way to prevent or signal that a variable is not allowed or expected to be modified. Meaning some one cannot enforce the value of PI.

If valued, propose draft.

stevehalliwell avatar Sep 27 '21 03:09 stevehalliwell

For value types/litterals this could happen at the compiler stage, the variable lookup finding a match and that match indicating it is a constant literal can push the literal rather than emiting the getlocal/global/prop etc.

For consts that hold expressions, either run them ahead of time or store their results and flag them as readonly/records.

While constants are valuable, they are not critical, we can make do just fine without them for a while.

stevehalliwell avatar Oct 06 '21 20:10 stevehalliwell

With readonly now in place for instances, we just need the ability to prevent sets on locals.

stevehalliwell avatar Dec 19 '22 05:12 stevehalliwell