A problem with the domain of function in the definition of limits My Stewart's Calculus gives the following definition of limit:

$f(x)$ is defined on some open interval containing $a$, except at
  possibly $a$. So, $\lim_{x\to a} f(x) = L $ if and only if for every
  number $\varepsilon>0$, there exists a corresponding number $\delta>0$
  such that, if $0<|x-a|<\delta$ then $|f(x)-L|<\varepsilon$.

I am not sure of the exact wordings of the above, but I am quite sure that its what meant it meant to say. However, my Introduction to Real Analysis: Bartle and Sherbert, gives:

Let $A \subseteq \mathbb{R}$, and let $a$ be a cluster point of $A$.
  For a function $f: A \mapsto \mathbb{R}$, a real number $L$ is said to be a limit of $f$ at $a$, if given any $\varepsilon>0$, there exists a $\delta>0$ such that if $x \in A$ and $0<|x-a|<\delta$, then $|f(x)-L|<\varepsilon$.

Now my problem is when considering, for example, if $f: A \mapsto \mathbb{R}$, where $A=\{ x: x \text{ is irrational} \}$, and $f(x)=0$. By Stewart's definition, $f$ can't be defined on any open interval around $0$, as there will always be a rational number in it. So it fails the first condition, and $\lim_{x\to 0} f(x)$ is not defined.
However, according to the definition of cluster point, there will always be one irrational $x$ that satisfies $0<|x-0|<\delta$ for every $\delta<0$. Hence $0$ would be a cluster point. Now, if $x\in A$, i.e. if $x$ is irrational and $0<|x|<\delta$ then obviously $0<\varepsilon$. So $\lim_{x\to 0} f(x)=0$.
What is going on?
 A: I agree with the comments: Stewart's definition can be applied to fewer cases. In Calculus, the choice of simplification is very appealing, since the most general case might require tools that cannot be presented in a first course. The most common simlpification is indeed about the domain of definition of the functions: most calculus books deal with functions defined on intervals. Why? Because $(a,b)$ is the basic example of open set of the real line, and $[a,b]$ is the basic example of compact set of $\mathbb{R}$.
Consider the theorem of Weierstrass: it holds true for any continuous function defined on any compact subset of $\mathbb{R}$ (and of course also for general topological spaces). However, most calculus books state it for continuous functions defined on $[a,b]$. As you noticed yourself, these authors lose some degree of generality, but sometimes they gain some degree of readability in proofs.
A: The two definitions agree when $f$ is defined on some open set containing $a$ (except, possibly, $a$).
The “extended” definition is very useful, though. For instance it doesn't require different definitions for the limit from the left or on the right. 
Suppose $f$ is defined on $(c,d)$ and $a\in(c,d)$. Then we can define two functions, say
$$
f_{-}\colon(c,a)\to\mathbb{R},\qquad
f_{+}\colon(a,d)\to\mathbb{R}
$$
as the restrictions of $f$ to the indicated intervals. Now, according to the extended definition,
$$
\lim_{x\to a^-}f(x)=\lim_{x\to a}f_{-}(x),\qquad
\lim_{x\to a^+}f(x)=\lim_{x\to a}f_{+}(x)
$$
(provided they exist, of course).
Also, you have no problem in doing something like
$$
\lim_{n\to\infty}a_n=\lim_{x\to 0}f(x)
$$
where the function $f$ is defined on the set $A=\{1/n:n>0,\text{$n$ integer}\}$. So, for instance,
$$
\lim_{n\to\infty}n\log\left(1+\frac{1}{n}\right)=
\lim_{x\to0}\frac{\log(1+x)}{x}
$$
where the function in the second limit is the restriction to $A$ of a function defined on $(-1,\infty)$ which has a limit at $0$, so the two limits coincide.
