You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue is a follow-up from http4s/http4s#3433.
I've struggled with this a bit and think it's quite problematic to embed string interpolations to uri"" and path"" of http4s (actually, it's so for every interpolated macros based on literally):
At the moment, compilation fails if invalid strings have been passed (underlying validate is calling at compile time).
means that we should check the value of foo at the runtime (generally, foo could be some computation, not a constant value). So bringing embedded string interpolations means we should proceed with runtime values at compile time (because of 1). I'm not that much a Scala macros astronaut, but am feeling it's probably impossible.
UPD: speaking more accurately, compile-time checking is only possible for the literal part of the passed string.
If anyone has insights about that, please share them here.
The text was updated successfully, but these errors were encountered:
Yes, that's correct. It's possible to support interpolation of constant values at compile time, but not possible to use non-constant values. Doing so would require changing the macro to return an Either[String, Uri] when there are one or more non-constant parts and Uri otherwise. This type switching would require a white box macro in Scala 2 and transparent inline in Scala 3.
To support interpolation of constant values, we could do something like this:
This is too limited though as it requires the args list to be strings. It would be nicer to support arbitrary types there. Overall, I don't think the complexity is worth it.
This issue is a follow-up from http4s/http4s#3433.
I've struggled with this a bit and think it's quite problematic to embed string interpolations to
uri""
andpath""
ofhttp4s
(actually, it's so for every interpolated macros based onliterally
):validate
is calling at compile time).means that we should check the value of
foo
at the runtime (generally,foo
could be some computation, not a constant value). So bringing embedded string interpolations means we should proceed with runtime values at compile time (because of 1). I'm not that much a Scala macros astronaut, but am feeling it's probably impossible.UPD: speaking more accurately, compile-time checking is only possible for the literal part of the passed string.
If anyone has insights about that, please share them here.
The text was updated successfully, but these errors were encountered: