What can be done without significant language change, in my opinion: string interpolation should not just use StringBuilder.append(...)
, but look for operator fun toString()
for interpolated objects (dynamically or statically). Then we can write the above example without the +
operator.
object SqlBuilder {
operator fun Column.toString(): String = "\"$name\""
}
val sql = buildSql { "select $id,$user from table" }