← Back to context

Comment by ndriscoll

11 hours ago

The "trivial" cases are also the cases people actually need like structured logging, sanitized HTML, and SQL.

SQL doesn't require interpolation, but it's much cleaner to write it that way and not have to explicitly do binding. It's not an "instead." Like I said, what the interpolator does is automatic safe binding with interpolation syntax.

The content known at compile time is the query template that you're binding. The point is a compile-time interpolator turns e.g. `sql"""select * from users where name=$name"""` into `Statement("select * from users where name=?").bind(name)`.

You can also have macro fragments as "inline def" functions in e.g. Scala so that they compose naturally. c.f. Quill[0].

[0] https://zio.dev/zio-quill/extending-quill

Over a year your compile time interpolator would cost far more time, because even annotation processors and equivalent type technology do make a compile slower, than you typing the old way.