D string interpolation
bitwise
bitwise.pvt at gmail.com
Sun Oct 4 17:53:55 UTC 2020
On Sunday, 4 October 2020 at 14:04:04 UTC, Mike Parker wrote:
> On Sunday, 4 October 2020 at 13:16:53 UTC, Imperatorn wrote:
>> [...]
>
> [...] so it will require at least one more round of community
> review before moving forward.
>
> DIP 1036:
> https://github.com/dlang/DIPs/blob/master/DIPs/DIP1036.md
I hope they change the syntax to favor readers of code, not
writers. As with D's templates, reading code is made more
difficult by needlessly adding syntactical variations for
language features.
Example:
writefln(i"I ate $apples and ${%d}bananas totaling $(apples +
bananas) fruit.");
> $apples
> $(apples + bananas)
If I was trying to quickly scan code to pick out variables,
there's two different things I would have to look for.
Example:
> Foo!int
> Foo!(bool, int)
Same problem.
> Foo;
> Foo();
Same problem.
I'm not sure if the reasoning is to try and reduce noise in the
"common" case, or to appease people that think not having to type
() will actually help them get things done faster, but neither
reason seems valid to me.
Also, why would the less significant part of the construct be in
the curly braces?
> ${%d}bananas
Why not like this?
> i"{apples} bar"
> i"{apples + bananas} bar"
> i"{bananas:%d} bar"
> Bar!(int)
> Bar!(bool, int)
> Bar();
> Bar();
In all honesty, part of the reason I lost interest in D is
because of the type of quirks listed above. I don't believe the
intended benefit, whatever it may be, is worth the sacrifice of
consistency.
More information about the Digitalmars-d
mailing list