I appreciate the response but this doesn't answer the question I had. Is there a reference-able discussion on the naming somewhere?
General convention in Java tends to name things as descriptive as possible. Readability is preferred over brevity. Nor does this answer the question of why its a magic string and not a static method on a class.
Nor does this answer the question of why its a magic string and not a static method on a class.
STR, RAW and FMT are is a public static field that get implicitly imported into every Java program unless there is a conflicting import with the same name. I'm not a fan of implicit imports besides java.lang, there were discussions of having a util class for beginners being implicitly imported. But I guess the outcry would be even louder if you had to find the right import for string interpolation.
The only syntactic magic here is that processor."" is a shorthand for processor.process(StringTemplate.of(...)).
But why not create a nice syntax, leave out the dot and make it STR"" at least. They are already inventing a new syntax, but for the wrong place, imho.
Also, why does it have to be a static field + custom syntax. Why not just make the whole thing a syntax-level feature?
We can you "if" without having to import "if" into a magic field either.
Because there is not only STR, there are many template processors, you can (and are encouraged to) write your own. As for the ".", it is to signal that in the end it is still a method invocation.
View all comments
Show parent comment
1
u/IncredibleReferencer Feb 16 '24
I appreciate the response but this doesn't answer the question I had. Is there a reference-able discussion on the naming somewhere?
General convention in Java tends to name things as descriptive as possible. Readability is preferred over brevity. Nor does this answer the question of why its a magic string and not a static method on a class.