The state of string interpolation

Jonathan Marler johnnymarler at gmail.com
Thu Dec 6 18:30:04 UTC 2018


On Thursday, 6 December 2018 at 18:06:51 UTC, Adam D. Ruppe wrote:
> I would take it one step further and put the other stuff in a 
> wrapped type from the compiler, so the function receiving it 
> can static if and tell what it is, so
>
> i"foo $(foo)"
> would be
>
> tuple("foo ", FromInterpolation("foo", foo))
>
>
> so you can identify when something was passed vs being 
> literally in the string. And it included the name as a string 
> so we can do some other crazy stuff too.
>
> i"foo $(a + b)"
>
> FromInterpolation("a + b", a+b)
>
> so you can then print
>
> a + b = 4
>
> [...]

Very neat idea.


More information about the Digitalmars-d mailing list