String interpolation, after a healthy debate on discord
WebFreak001
d.forum at webfreak.org
Tue Dec 14 11:11:31 UTC 2021
On Tuesday, 14 December 2021 at 09:50:15 UTC, bauss wrote:
> On Tuesday, 14 December 2021 at 09:35:27 UTC, WebFreak001 wrote:
>> [...]
>
> While I completely understand the proposal then I think it's
> the wrong approach as it adds an infinite amount of complexity
> for something that barely solves any issues that exist today.
I think the complexity for the syntax and the language itself is
quite little - and it's basically the same thing as JS template
string literals too, but with the special ignore cases for
letters i/r/q. It's not going to solve any issues if nobody
implements it. It's completely just an extension to the language,
but then is going to be a big help to making both more pretty
code with `text`
The implementation of these functions is going to be a little
complex.
> Arguably while it solves some problems it's definitely going to
> introduce new issues with it.
I can see that the new istring calling syntax could introduce
issues if we want to add more string types through prefixes in
the future, but I think that would be worth it for a quite
versatile feature. The feature in other languages (like JS) has
shown great use-cases, an example:
https://github.com/kay-is/awesome-tagged-templates
^ that link contains lots of cool examples we could have in D
like that too. Some type-safe data structure creation helper,
some string / template language processors with nicer syntax,
some useful every-day utilities.
I think overall it will solve more issues than introducing new
ones.
> Has D forgotten Scott's talk, along with the common saying that
> sometimes less is more?
>
> D has so many concepts that it's almost impossible to wrap your
> head around D idioms and be an expert at D since there are so
> many edge-cases for each feature, so many issues that each
> feature tries to solve.
>
> Every feature D gets added is always added in the most complex
> way possible to solve as many problems as possible, instead of
> just solving a handful of problems that are mostly relevant
> then D tries to solve ALL problems, relevant or not.
>
> It's ultimately D's downfall that features are too complex.
it's a complex feature. However you don't really care about its
implementation or complexity unless you want to implement a
function for it yourself. All the average user might even want to
think about is `text"..."`, which you could look at like it's
special language syntax. It's something library authors can use
and document to make more readable, better library functions.
Overall I think there is more benefit in adding this than not
adding this.
More information about the Digitalmars-d
mailing list