implementation
implementation copied to clipboard
Update Kotlin implementation to support Kotlin Multiplatform
KotlinVerbalExpressions only targets Kotlin/JVM, which is not a big surprise since the repo hasn't been updated since Kotlin/JS, Kotlin/Native, and Kotlin/WASM have had more prominent releases.
VerbalExpressions would be especially useful for Kotlin Multiplatform, as currently it is difficult to create Regexes that perform identically on each platform. This is because currently each Kotlin target delegates to the Regex engine available at runtime, which can differ significantly between platforms.
Update KotlinVerbalExpressions
I would like to update the KotlinVerbalExpressions repo. I propose the following updates:
- Update the Gradle version and build config
- Update Kotlin from 1.2 to 1.8 (the latest version)
- Migrate the build config to use Kotlin Multiplatform, but still target Kotlin/JVM
I have made a demonstration PR for this work: https://github.com/aSemy/KotlinVerbalExpressions/pull/1
Kotlin Multiplatform
What is more difficult to determine is how to support additional Kotlin Multiplatform targets:
- Kotlin/JS
- Kotlin/Native
- Kotlin/WASM
I see two approaches:
-
VerbalExpressions can be written so that the platform's Regex engine does not have any impact.
This would be the best solution, because then KotlinVerbalExpressions could be written in common Kotlin code, and would not need to worry about platform specific details.
I suspect the best approach for this is to try and use JSVerbalExpressions as a basis, since Javascript are also dependent on the available Regex engine, so perhaps it has already overcome the same problem that Kotlin Multiplatform faces now?
-
KotlinVerbalExpressions uses expect/actual to delegate to platform specific VerbalExpression implementations. For Kotlin/JS and Kotlin/JVM this would be easier, since there are already VerbalExpressions implementations. However, Kotlin/Native requires a pure-C implementation, and I don't think VerbalExpressions has a pure-C implementation?
CC @zsmb13 👋, since you originally implemented KotlinVerbalExpressions way back when, and would probably be able to help with publishing a new version?