TITLE: Why does Munkres define functions in a seemingly complicated way?
QUESTION [6 upvotes]: In Munkres's extremely careful and well-written textbook, Topology (2nd Edition), he defines functions as follows. First he defines a rule of assignment as a subset of a cartesian product $r\subset C\times D$ where each element of $C$ appears as the first coordinate of at most one ordered pair belonging to $C\times D$. The domain and image set of $r$ are then defined as the set of all first coordinates and all all second coordinates of $r$ respectively. Finally, a function is defined to be a rule of assignment together with a set $B$ that contains the image set of $r$. $B$ is called the range of $f$, and the function is finally denoted by $f\colon A\to B$ if $A$ is the domain of $f$. Thus a function is defined by first taking a relation in $C\times D$, shrinking $C$ to the domain $A$, shrinking $D$ to the image set, and then enlarging the image set to a possibly different (from $D$) set $B$. This seems very complicated to me. I don't see what the relevance is of introducing the sets $C$ and $D$ to begin with. A much more natural definition would be simply that a function $f\colon A\to B$ is a relation $r\subset A\times B$ such that every $a\in A$ is the first coordinate of exactly one ordered pair.
I know Munkres did this for a reason, but I have not located where in the book he uses the more elaborate definition. I know many readers of math.stackexchange are pretty familiar with Munkres's book, so I wonder if anyone has any insight as to why the more complicated definition is useful.
Edit: As Asal Beag Dubh suggested, I want to emphasize that my question is what is the point of introducing $C$ and $D$ instead of sticking with $A$ and $B$.

REPLY [4 votes]: I can see a purpose for $C$, though I don’t know whether Munkres ever actually does anything with it. (I have the first edition.) At times one wants to consider partial functions from a set $C$ to a set $D$, meaning functions whose domains aren’t necessarily all of $C$. These are what Munkres is picking out as rules of assignment. One may quite reasonably wish to reserve the notation $f:A\to B$ for the case in which $A=\operatorname{dom}f$, so if $f$ is a partial function from $C$ to $D$, one would write $f:\operatorname{dom}f\to D$, not $f:C\to D$.
I don’t, however, see any real point to distinguishing $B$ from $D$: I can’t offhand think of a setting in which one would consider partial functions from $C$ to $D$ with different codomains; different ranges, yes, but not different codomains. (My codomain appears to be Munkres’ range, and my range appears to be his image set. I think that my terminology is more common.)