On Monday, 2 February 2026 at 06:54:53 UTC, Lars Johansson wrote:
On Sunday, 1 February 2026 at 20:49:34 UTC, monkyyy wrote:
On Sunday, 1 February 2026 at 12:54:15 UTC, Lars Johansson
wrote:
I put templates on the shelf for now, my skill level is to
low to understand templates.
You need 3 patterns total to write every range function in the
style I suggest; I stand by my original suggestion; the
complexity of template hell comes in when you try to annotate,
introspect, or have a some kind of big ask.
Phoboes annotates functions and explodes its line count often
by 10x to 100x
I do not follow. Are you implying there are a category of
templates that is relatively easy to understand, and I can
avoid what you call template hell. Can you please be a bit more
explicit and give an example.
the 3 patterns that are enough to write unannotated range
functions:
voldemort types: if you have some kind of templated function,
structs defined inside them just work
```d
auto map(alias F,R)(R r){
struct map_{
R r;
auto front()=>F(r.front);
void popFront(){r.popFront;}
bool empty()=>r.empty;
}
return map_(r);
}
```
lazy templates: given an empty template argument list, a name can
exist without being initialized
```d
auto bar(R)(R r){
struct maybehaslength{
R r;
auto front()=>r.front;
auto length()()=>r.length;
} // ^ ^
return maybehaslength(r);
}
unittest{
auto foo=iota(int.max).filter!(a=>a>100).bar;
assert(foo.front==101);
// assert(foo.length); //errors out here because filter cant
define length
}
```
understanding default argument resolution; if you want
counter(10), counter(5,10), and counter(3,7.5,double(.34)); to
all compile from a single header youll need to understand the
headers thats, not that trivial.
---
Templates are bad lambda calculus machines that create turning
machines; if you need to *calculate* something, well, thats means
learning what I mean by that; if you dont, you dont need a lick
of theory.