I just created a compiler plug-in for Kotlin that ...
# feed
a
I just created a compiler plug-in for Kotlin that lets you do Scala-style interpolation (a.k.a JEP-430 in Java-land) for Kotlin strings
"with $dollar $sign $variables"
capturing the variables before they are spliced into the surrounding string. This allows for third party Kotlin libraries to create functionality like sql-prefixed strings e.g:
Copy code
val ps: PreparedStatement = sql("SELECT * FROM person WHERE name = $joe")
...and they'll get captured into an array BEFORE being spliced. So you can then put them into a PreparedStatement correctly without worrying about SQL-injection attacks! Using this kind of functionality Scala libraries like Doobie and Quill allow a set of rich SQL operations. Hopefully now Kotlin libraries will be able to create similar things. (P.S. Currently the library is JVM-only, if there's an ask for KMP I'll look into it) (UPDATE I am currently waiting for approval from plugins.gradle.org to be able to publish the plugin) https://github.com/deusaquilus/Terpal
🆒 11
K 7
scala 1
❤️ 4
m
a
Hi @Mohammad Zaki. I'm waiting for approval from plugins.gradle.org right now (silly me for not knowing I needed to do that 😅). I'll hit the link as soon as I can actually publish the library.
Update - The plugin is now fully approved and available on plugins.gradle.org.
m
Good to hear that