support for the 'const' keyword?
Posted: Sat Feb 19, 2011 1:55 pm
I have a few constants defined as globals that I use in my system that I make sure to treat very delicately when evaluating them, having one change because of a programing mistake would be detrimental to the system (as is the use case for most constants constructs).
I noticed rhino supports the const keyword, however if I try to use it in a global definition servoy becomes quite unhappy and sees it as a syntax error. Is the support already in Servoy and I'm perhaps not assigning it correctly?
Of course the ECMAScript implementation of constants leaves a bit to be desired, I would much prefer it to throw an exception in the event something tries to re-assign the value, much like every other language that supports constants that I can think of right now, but we take what we can get I guess.
I noticed rhino supports the const keyword, however if I try to use it in a global definition servoy becomes quite unhappy and sees it as a syntax error. Is the support already in Servoy and I'm perhaps not assigning it correctly?
- Code: Select all
Ryan-Parrishs-MacBook-Pro:~ rparrish$ rhino
using CLASSPATH=/usr/local/bin/rhino/*:/usr/local/rhino1_7R2/*
Rhino 1.7 release 2 2009 03 22
js> const test_constant = 12345
js> test_constant
12345
js> test_constant = 54321
54321
js> test_constant
12345
js>
Of course the ECMAScript implementation of constants leaves a bit to be desired, I would much prefer it to throw an exception in the event something tries to re-assign the value, much like every other language that supports constants that I can think of right now, but we take what we can get I guess.