Norbert Kiesel
06/03/2026, 5:50 PM[3,1,4] as a shorter alternative for listOf(3, 1, 4). Are there now also plans to support using /num=(\d+)/ as alternative for Regex("""num=(\d+)""")?ephemient
06/03/2026, 6:28 PMRegExp`num=(\d+)`
however that probably won't be coming to Kotlin anytime soon https://youtrack.jetbrains.com/issue/KT-52924. a similar proposal in Java has also been partially implemented but run into some design issuesNorbert Kiesel
06/03/2026, 11:10 PMconst numReg = /num=(\d+)/
instead of
const numReg = Regex("""num=(\d+)""")
Of course, / is already used for other stuff (comments, division), but I do not see a possible case where it would be unclear whether is would be a regex or something else.
Now Typescript e.g. also allows to e.g. use /num=(\d+)/i instead of Regex("""(?i)num=(\d+)"""), but I could see Kotlin using /(?i)num=(\d+)/.jw
06/04/2026, 2:22 AMIan Botsford
06/04/2026, 5:52 PM/foo/ would create a backing val inlineRegex = Regex("foo") and use that instead of creating a new Regex every time it's invoked. Presumably it could even go farther and offer some kind of automatic "regex interning" similar to string interning.ephemient
06/04/2026, 5:53 PMIan Botsford
06/04/2026, 5:56 PM/foo${bar}baz/? I don't believe JS/TS allow that. Suppose it's an open question whether the equivalent feature in Kotlin would. 🤷♂️ Is interpolation the only/biggest complication for caching?ephemient
06/04/2026, 5:57 PMNorbert Kiesel
06/04/2026, 5:57 PMephemient
06/04/2026, 5:57 PMNorbert Kiesel
06/04/2026, 5:58 PM/foo${bar}baz/ as well. Of course, should then not be globally cached,ephemient
06/04/2026, 5:58 PMNorbert Kiesel
06/04/2026, 5:58 PMNorbert Kiesel
06/04/2026, 6:00 PM[] instead of listOf" which for me has no semantic changes, but just makes the code a bit more compact.Ian Botsford
06/04/2026, 6:04 PMval a = [1]; val b = [1] to result in two different arrays/references. Not so with regular expressions.
with a hidden complexity like keeping a global table of recently compiled regexesThe JVM already does string interning, which keeps a global table of recently referenced string constants. Feels pretty similar to me.
Norbert Kiesel
06/04/2026, 6:08 PM"foo".toUpperCase() at compile time. So perhaps if we would limit // to not support string interpolation, could then be handled the same way.