Functions can’t be used to handle undefined values either. A function is a mapping, f, from one set to another such that each element of the originating set gets mapped to one and only one element of the target set. This, by definition, requires that all values in the originating set get mapped to something in the target set. So there are no undefined values as such.
Function spaces can’t always be viewed as vector spaces because there may be no concept of addition of functions or a concept of scalar multiplication on the functions that behaves well with whatever notion of addition the functions satisfy.