Make final behave like var

Kenneth Fogel kfogel at dawsoncollege.qc.ca
Sat Oct 26 15:45:30 UTC 2024


Just a thought that came up in a reply to a LinkedIn post that contended that 'final' was useless because the JIT could figure out what was final and what was not. I disagreed because I felt it would impact the readability of code. It was then that what may be a silly idea struck me. Could the keyword 'final' behave like 'var'? I do like that you can defer initializing a final variable whereas a var variable must be initialized right away. However, if we want to encourage a greater use of constant variables (those two words always sound like an oxymoron), and reduce decorations then could final be made to work like var? I shudder to say this, but could we use the term 'const' so as not to interfere with existing code. Even have an 'sconst' if we want it static, too.

Just thinking out loud. Feel free to use my name in vain.

Ken

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/discuss/attachments/20241026/1f29e343/attachment-0001.htm>


More information about the discuss mailing list