Is a C ++ functor a functor in the sense of category theory?

The C ++ functor is a class that supports operator overloading (). Is this a functor in the sense of category theory? What are objects and morphisms?

+4
source share
3 answers

No, as Khurkil said, despite the collision of names deduced by "objects" in object-oriented programming, OOP functions are not related to category theory functionals. A better match with OOP would be to rename OOP classas categorywell as type conversion as functors. Something like that:

category Shape;
category Rectangle : forgetful functor Shape;
category Polygon : forgetful functor Shape
{
    functor Polygon( Rectangle & );
};

instead

class Shape;
class Rectangle : public Shape;
class Polygon : public Shape
{
    implicit Polygon( Rectangle & );
};

, , , , , , .

+4

.

IMO ++ "" - " ".

Java , "", ++, , - , "".

, , -, . , , " ", , . "", , . " - , ". " " , , , , , , .. . .:)

+3

No; as far as I know, the etymology is that a β€œfunctor” as related to an object of a function is a thing that does something (thus, using a naming pattern like ---- or), where it's just a function, and other names, such as "functor" or "functional", sound uncomfortable.

+1
source

All Articles