On Wednesday, 13 November 2019 at 14:01:13 UTC, BoQsc wrote:
I don't like to see exclamation marks in my code in as weird
syntax as these ones:
to!ushort(args[1])
s.formattedRead!"%s!%s:%s"(a, b, c);
I'm not sure why, but template instantiation syntax is
prevalent in the documentation examples of d lang libraries. It
almost seems like every other example contains at least one or
two of them.
It look horrible, and I'm feeling like I'm being forced/coerced
to learn from examples that do not provide alternatives to the
template instantiation syntax. Even if the alternative examples
were provided, why would anyone want to have syntax as ugly and
weird as current template instantiation syntax with exclamation
point in the middle of the statement with all other things that
come with it.
A good thing is that in many cases the template instance
parameters can be deduced from the arguments used:
---
import std;
void main()
{
assert(max(0,1) == 1);
// same as assert(max!(int,int)(0,1) == 1);
}
---
This feature is known as "IFTI" see §6,
https://dlang.org/spec/template.html#function-templates.
You're not forced to use the D templates but you'll have to write
many code by yourself because the standard library use them
everywhere.