More fun with autodecoding
H. S. Teoh
hsteoh at quickfur.ath.cx
Thu Sep 13 22:53:10 UTC 2018
On Thu, Sep 13, 2018 at 06:32:54PM -0400, Nick Sabalausky (Abscissa) via Digitalmars-d wrote:
> On 09/11/2018 09:06 AM, Steven Schveighoffer wrote:
> >
> > Then I found the true culprit was isForwardRange!R. This led me to
> > requestion my sanity, and finally realized I forgot the empty
> > function.
>
> This is one reason template-based interfaces like ranges should be
> required to declare themselves as deliberately implementing said
> interface. Sure, we can tell people they should always `static
> assert(isForwardRage!MyType)`, but that's coding by convention and
> clearly isn't always going to happen.
Yeah, I find myself writing `static assert(isInputRange!MyType)` all the
time these days, because you just never can be too sure you didn't screw
up and cause things to mysteriously fail, even though they shouldn't.
Although I used to be a supporter of free-form sig constraints (and
still am to some extent) and a hater of Concepts like in C++, more and
more I'm beginning to realize the wisdom of Concepts rather than
free-for-all ducktyping. It's one of those things that work well in
small programs and fast, one-shot projects, but don't generalize so well
as you scale up to larger and larger projects.
T
--
A program should be written to model the concepts of the task it performs rather than the physical world or a process because this maximizes the potential for it to be applied to tasks that are conceptually similar and, more important, to tasks that have not yet been conceived. -- Michael B. Allen
More information about the Digitalmars-d
mailing list