DIP 1027--String Interpolation--Final Review Discussion Thread
Jacob Carlborg
doob at me.com
Thu Feb 6 10:53:18 UTC 2020
On Wednesday, 5 February 2020 at 22:30:14 UTC, Adam D. Ruppe
wrote:
> Anything with an @attribute makes me "bleh". I'd really rather
> just have the explicit function to build a string. The explicit
> function is not a big hassle while being more friendly to
> several other uses.
I disagree. This will make it feel more like a real string. I'm
sure there will be complains and confusion that for some strings
`.idup` is required and for some it's not.
> I'm not convinced that assigning to a string variable will
> actually be the most common usage though. You're surely
> creating this string to do something... and the variable
> doesn't actually do anything. You're surely going to pass it to
> a function eventually.. and often sooner rather than later.
It's not the actual assignment that I referred to. It's the how
it's formatted. I don't think the most common use case would be
to call a function like `sql` or `jsx`. I think it would be to
format the string as `std.format.format` would do. Then if you
assigne the string to a variable or pass it to a function that
expects a `string` is less interesting.
> I use `writefln` more often than `format`, for example. Most my
> cases of `"x" ~ to!string(y)` are in order to prepare a call to
> a function (actually most of those in my code are actually to
> make the `new Exception` argument - which I believe is bad code
> anyway, I'm just lazy af. I'd prolly just .idup an interpolated
> string there).
Yeah, exactly. But with my suggestion you would need the extra
call to `.idup` and it would feel more like an actual string.
Then that it goes through an extra struct will be an
implementation detail in most case.
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list