What is "FilterResult" type?

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Sep 8 11:45:23 PDT 2015


On Tuesday, September 08, 2015 11:08:57 Bahman Movaqar via Digitalmars-d-learn wrote:
> However, I have made this a strict practice of mine to specify
> the full signature of my public API.

If your API returns ranges, that's general not only bad practice but
arguably impossible. Most range-based functions purposefully return
Voldemort types (the type is declared inside of the function, meaning that
you cannot name it). FilterResult really should be to, but I think that it's
not in order to work around a bug. Regardless, it's private and should never
be used explicitly.

If you want to put a range type in an API, you're forced to do stuff like

typeof(rangeFunc!someFunc(SomeOtherRange.init)) myFunc(int);

If you're returning a range, you should be returning auto. The documentation
should then say whether it's an input range, forward range, etc. - but you
should pretty much never be using range types explicitly. Your code will
become an unmaintainable, unreadable mess if you try. And really, it's
unnecessary. Simply having the documentation say what sort of range it's
returning is plenty. Exact types are unnecessary in this case and
counterproductive.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list