M. Spivak in Calculus on Manifolds defined differentiability as:
$f:\mathbb R^n\to\mathbb R^m$ is differentiable at $a\in\mathbb R^n$ if there exists a linear transformation $\lambda:\mathbb R^n\to\mathbb R^m$ such that $$\lim_{h\to0}\dfrac{|f(a+h)-f(a)-\lambda(h)|}{|h|}=0$$
$\lambda$ is denoted by $Df(a)$ which is called the derivative of $f$ at $a.$
He made the following remark regarding the above definition:The definition of $Df(a)$ could be made if $f$ were defined only in some open set containing $a.$
Here is the problem I am facing. Why the domain of $f$ needs to be open for the definition to work?
If $f$ is not defined in some neighborhood (open set) containing $a$ then we cannot make sense of an expression such as $f(a+h)$. This is what I mean by there are directions we cannot approach from. If $a$ is on the boundary of the domain of $f$ then for any neighborhood of $a$ we have point which are not in the domain of $f$. These are valid points to use when taking the limit though, which means will have issues when we try to evaluate them in expressions like $f(a+h)$.