The domain of a function as a function: the "domain-function" The domain of a function $f:X\to Y$ is normally defined as $\operatorname{dom}f\equiv X$, but I would like the domain-function $\operatorname{dom}$ to be a funtion itself, i.e. I would like to define the function $\operatorname{Dom}$ defined by: 
$$\forall X\,\forall Y\,\forall f\,(f:X\to Y\Rightarrow\operatorname{Dom} f\equiv X)$$
Now $\operatorname{Dom}(\operatorname{Dom}(\cdot))$ would be the set of all functions, and $\operatorname{Ran}(\operatorname{Dom}(\cdot))$ would be the set of all sets. 
It is however impossible to construct the set of all sets, by Russel's paradox. My question is what I have done wrong in the above definition, and how to define $\operatorname{Dom}$ as a function. 

The solution is to remember that there is such a thing called a class function. This is a function whose domain is a proper class. It is not an object of the universe, sure, but we can treat it as such for "practical reasons". Namely, every restriction to a set, is in fact a function (in the usual sense of the word). And we use these things all the time.
For example $x\mapsto\mathcal P(x)$ is a class function; and $x\mapsto|x|$ is a class function; and $x\mapsto x\cup\{x\}$ is a class functions.
And so, $x\mapsto\operatorname{Dom}(x)$ is also a class function, and you have to ask yourself, does it really matter that it is a class function? 
