4 ms·
Wouldn't this be better: private static final Log log = const Log.getLog("yo"); instead of all that rigmarole around ComputedConstants?
by java-man 3y ago
Wouldn't this be better:
private static final Log log = const Log.getLog("yo");
instead of all that rigmarole around ComputedConstants?
- lolinder 3y agoThis proposal is trying to implement lazy evaluation without adding any new syntax. Your version would require a change to the parser, where this is just a new standard class. A commenter above points out that there's a competing proposal that does introduce new syntax in the form of a `lazy` keyword: https://news.ycombinator.com/item?id=36993023 https://news.ycombinator.com/item?id=36993023
- samus 3y agoThe architects are wary about introducing new syntax into the Language. If it can be accomplished with an API, it should be done that way. Also, this keyword would probably use something like ComputedConstants in the background, and doing it this way would sweep that under the rug, which is also generally not how most Java features work. The delayed nature of this initialization is also not explicitly highlighted (unlike the lambda we would have to use with ComputedConstants), which will eventually bite people.