How to describe the function operation "composition", $\circ$, using the convention of function notation. I am in the process of reading Tao's Analysis I after completing Pinter's A Book of Abstract Algebra (pretty new to maths).
It recently occurred to me that all operations, ($+,*, $ etc), seem to behave like functions. This made me think about the function operation of composition, $\circ$, and how one could possibly define composition in the convention of function notation.
I've been playing around with the notation a little bit, and this is what I have so far. 
Firstly, I'm pretty certain that composition behaves as a binary operation, and the domain is effectively the set of all ordered pairs of all functions (which I will call $T \times T$...where $T$ by itself is simply the set of all functions). From what I can tell, the only proposition $P(f,g)$ that needs to be fulfilled for composition is: $\forall x \in \operatorname {dom}(f), f(x) \in \operatorname{dom}(g)$.
Therefore, we have the following definition of composition:
$\circ : T \times T \to T$ 
$(f,g)\mapsto h$ s.t. $\forall x \in \operatorname {dom}(f), f(x) \in \operatorname{dom}(g)$
I'm sure this is probably incorrect, so any assistance would be greatly appreciated!
EDIT:
After reading some of the comments, it seems like I need to make the following change: 

$(f,g) \mapsto h=g(f(x))$ s.t. $\forall x \in \operatorname {dom}(f), f(x) \in \operatorname{dom}(g)$

 A: Your definition is fine if you just modify composition to be a function from the set
$$\{(f,g) \in T\times T : x\in \operatorname{dom}(f) \Rightarrow f(x)\in \operatorname{dom}(g)\}$$
but this is a somewhat unusual way to axiomatize composition as an operation. More typical is that one regards a function $f:A\rightarrow B$ to have a fixed domain ($A$) and a fixed codomain ($B$) which may be different (larger) than the image $f(A)$. Functions $f:A\rightarrow B$ and $g:C\rightarrow D$ can then only be composed as $g\circ f$ if $B=C$.
This is a bit counterintuitive at first since it means that you wouldn't be allowed to compose a function $f:\mathbb R\rightarrow \mathbb R_{\geq 0}$ with a function $g:\mathbb R \rightarrow \mathbb R$ as $g\circ f$ since the codomain of $f$ doesn't match the domain of $g$, even though it's a subset. The fix to this is to note that since $\mathbb R_{\geq 0}\subseteq \mathbb R$ there is an inclusion map $\iota : \mathbb R_{\geq 0}\rightarrow\mathbb R$ define by $\iota(x)=x$. Then, we can compose $g\circ \iota \circ f$ as desired.
This definition is convenient because it turns out that sometimes we really do care about the codomain - for instance, in linear algebra, there's a notion of duality where you can take a map $f:V\rightarrow W$ and "reverse" it into a map $f^*:W^*\rightarrow V^*$ called the adjoint of $f$, where different codomains would give different adjoints - hence we have to record the codomain. In algebraic topology, the codomain sometimes matters since if you take a circle and map by inclusion it into a plane, the circle can suddenly be shrunk to a point, which it couldn't before - meaning that an inclusion map did something meaningful and that we shouldn't ignore it.
Then, essentially, composition can be defined by first choosing some collection of functions $T$ and a collection of possible domains and codomains $O$, and letting $\operatorname{dom},\operatorname{codom}:T\rightarrow O$ be functions taking a function to their domain and codomain respectively. Composition is then defined to have the domain of
$$\{(g,f) \in T\times T : \operatorname{dom}(g) = \operatorname{codom}(f)\}$$
and an output in $T$ such that $\operatorname{dom}(g\circ f) =\operatorname{dom}(f)$ and $\operatorname{codom}(g\circ f)=\operatorname{codom}(g)$ and such that $h\circ (g\circ f)=(h\circ g)\circ f$. One also desires that for every possible object $o$ in $O$ there be some identity map $\operatorname{id}_o$ such that $f\circ \operatorname{id}_o = f$ and $\operatorname{id}_o\circ f = f$ whenever these compositions are legal. These definitions describe a category - and "functions between sets" is one example of a category, but there turns out to be a lot of other examples, in the same way that "the integers" is an example of a ring, but not the only one - for instance, there's a category of vector spaces with linear maps between them and a category of topological spaces with continuous maps between them, all satisfying this same general setup for composition.
