what is the point of functor ?
Steven Schveighoffer
schveiguy at yahoo.com
Fri Jun 22 15:17:52 UTC 2018
On 6/22/18 10:06 AM, Flaze07 wrote:
> recently, I visited the glossary and saw that functor exist in D...I
> know that functor exist C++ as a way to easily allow higher order
> function, but since D already has function and delegates, is there a
> point to functor ?
D covers a lot of programming paradigms. It has Java-like classes and
interfaces, and C++-like functors, along with pure functions, (good)
templates, immutable data, concurrency, etc.
It's meant to make it easy to transition to D from the language you are
used to.
There's no specific reason to use functors, but if you want to, you can,
as most of std.algorithm supports them (see
https://dlang.org/phobos/std_traits.html#isCallable).
-Steve
More information about the Digitalmars-d-learn
mailing list