need to be specified explicitly? can't the compiler check automatically if the keyword is applicable ? or is there a scenario where you wouldn't want its optimizations ?
a
Adam Powell
05/02/2021, 3:17 PM
const
gets compiled into call sites. If you're writing a library, the value of
const
properties is part of your binary compatibility contract and you can't change the values of those constants across versions without breaking other compiled code
👆 2
l
LastExceed
05/02/2021, 3:20 PM
ty
c
CLOVIS
05/02/2021, 9:03 PM
Also, the JVM is more or less able to inline stuff at runtime anyway, so not using
const
shouldn't be too much of a difference
m
Michael Böiers
05/03/2021, 6:40 AM
CONSTants are “deeply” immutable - use them for things which are not only immutable, but will NEVER change.