8 ms·
You can not use the excuse of the backward compatibility twice. If the string template is prefixed by a processor STR."foo" instead of "foo" then you do not ne
by _old_dude_ 3y ago
You can not use the excuse of the backward compatibility twice.
If the string template is prefixed by a processor STR."foo" instead of "foo" then you do not need \{variable} instead of $variable.
- jitl 3y agoThey want to ensure the new interpolation sequence is a compiler error in non-template strings, so that the incorrect “hi \{name}” is an error instead of silently doing the wrong thing. Using \{ accomplished this because it’s an unknown escape sequence in older Java (so forbidden there), and in new Java will have the more specific error of “yo you forgot the template processor at the start of your template”.
- _old_dude_ 3y agoYes, you do not get a compile time error, but visually a big STR is front is enough "${variable}" vs STR."${variable}" And editors will use different colors. Using \ or $ is not about backward compatibility but about ergonomics.
- usrusr 3y agoYou don't want friction on the default path to be too low because that would inevitably increase the occurrence of default path where it must not be used, e.g. cause sql injections. Much easier to accidentally write something that boils down to "\{bobby}" where it should have been SQL."\{bobby}" than STR."\{bobby}" instead of SQL."\{bobby}" (i admit that this argument would work better if STR was typographically more different from the name you'd inevitably use for an SQL statement processor)