How do we define the domain of a function with removable and nonremovable discontinuities? For instance consider the function 
$$f(x) = \frac{x-2}{(x-2)(x+2)}$$
I don't understand why some discontinuities are considered "removable". Yes, we can cancel out the $x-2$'s but isn't this invalid at $x=2$ because it's like canceling out $\frac{0}{0}$? I don't understand why we're allowed to do this.
Anyway if we "remove" that piece we get:
$$f(x) = \frac{1}{x+2}$$
Which has a discontinuity at $x=-2$ but we can't "remove" that. 
So we end up with two discontinuities -- do we define the domain to include or exclude these? Is the domain all real numbers? All except $2$? All except $-2$? All except $-2, 2$?
 A: You clearly understand the algebra, and the idea behind "removable singularity". The definition of the domain is a little subtle (and usually not particularly important, given your understanding).
The expressions on the right in
$$f(x) = \frac{x-2}{(x-2)(x+2)}$$
and
$$g(x) = \frac{1}{x+2}$$
define the same function where both make sense. That function has an unremovable singularity at $x=-2$.
The domain of $g$ contains the point $x=2$; the domain of $f$ does not, so strictly speaking they are not the same function. But the limit of $f$ at $x=2$ does exist, and has value $g(2) = 1/4$. That's exactly what we mean when we say the singularity is removable.
A: The domain of $f$ is $\mathbb{R} \backslash \{-2,2\}$, because at this two points $f$ is not defined. Having said that, some singularities are better behaved than others: $f$ goes to infinity as $x \to -2$, whereas $\underset{x \to 2}{\lim} f(x) = \frac{1}{4}$ is well-defined. This is exactly the difference between poles and removable singularities.
A: The discontinuity at $x=2$ can be removed because $\lim_{x\to2}f(x)=1/4$. When 'removing' the discontinuity, we define a new function $f^\prime$ that takes on the values of $f$ at all points in the domain of $f$ and $f^\prime(2)=1/4$, thereby extending the domain.
The discontinuity at $x=-2$ cannot be removed because the limit there is improper: $\lim_{x\to-2}f(x)=\infty$.
