There are several possibilities for defining out-of-domain behavior of
function values. We chose the empty set in large part because it is
very convenient to have function values exist unconditionally (fvex and
consequently ovex).
Another possibility is to define
out-of-domain function value to be the universe _V, which has the
advantage of providing us with a simple test (sethood) to determine
whether we are using the function outside of its domain. Alexander van
der Vekens studied an alternate function value definition with this
property; see df-afv and associated theorems in his mathbox.
There
is a certain philosophical elegance to the df-afv approach that I can
appreciate, but from a practical point of view the drawback is that
proofs that a function value exists would be significantly longer. The
long proof of cnfex (whose author had presumably overlooked ovex)
actually illustrates this point nicely - this is the kind of thing we
would have to do frequently if we used a function value definition whose
out-of-domain behavior evaluated to _V. The unconditional fvex and
ovex are used 2783 and 1913 times respectively in
set.mm. With df-afv,
the size of
set.mm would grow considerably and would make function value
existence a major part of many otherwise short proofs, obscuring the
more important parts of the proof.
There was a discussion of df-afv in this thread:
https://groups.google.com/g/metamath/c/cteNUppB6A4/m/1qv4j6wyAgAJNorm