TITLE: Domains of continuity
QUESTION [8 upvotes]: I was playing around with the definition of uniform continuity, and realized that a nice application of it is the possibility to extend functions.
For example, suppose we are given a uniformly continuous function $f:\mathbb{Q}\to\mathbb{R}$.
By uniform continuity, it is easy to see that such a function extends (uniquely of course) to a continuous function $f:\mathbb{R}\to\mathbb{R}$.
If we drop the uniform continuity assumption and demand only that $f$ to be continuous, this is no longer true, as easily demonstrated by $f(x) = \frac{1}{x-\pi}$ which is continuous on $\mathbb{Q}$ but cannot be extended to a continuous function on all of $\mathbb{R}$.
Which brings me to my question: Is there a nice description of the sets $A\subseteq \mathbb{R}$ which have the following property: there is a function $f:A\to \mathbb{R}$ which is continuous, but for any $x \notin A$, $f$ cannot be extended to a continuous function on $A\cup \{x\}$ ?
Certainly open sets have this property, because if $A$ is open and $B$ is its complement, then we may define $f:A\to \mathbb{R}$ by $f(x) = \frac{1}{dist(x,B)}$.
Conversely, are all such sets open?
Edit: per Robert Israel nice examples, it appear that not all such sets are open. I still wonder if there is a nice description of this sets?

REPLY [3 votes]: The sets with the property are exactly the dense $G_\delta$'s.
1) Suppose $A \subset \mathbb R$, and $f$ a function defined on $A$.
Let $G$ be the set of points $x$ such that either $x$ is not a limit point
of $A$ or  $\lim_{t \to x} f(t)$ exists.  Then $G = \bigcap_{n \in {\mathbb N}} U_n$ where
 $$U_n = \{x \in {\mathbb R}: \text{ there is }\delta > 0 \text{ such that for all } y,z \in A \cap (x-\delta, x+\delta),\ |f(x) - f(y)| < 1/n\}$$
Note that $U_n$ is open, so $G$ is a $G_\delta$ set.  If $A$ has the property, 
we must have $A = G$, because $f$ can be extended continuously to any member of $G$ not in $A$; in particular, $A$ must be a $G_\delta$.  As previously noted, $A$ must be dense.
2) If $A$ is a dense $G_\delta$, write $A^c = \bigcup_{n} E_n$ where $E_n$ is closed and nowhere dense.  Define $$f(x) = \sum_{n} 3^{-n} \sin(1/\text{dist}(x,E_n))$$.  Since each summand is continuous on $A$ and the series converges  uniformly there, $f$ is continuous on $A$. On the other hand, if $x \notin A$, 
say $x \in E_n \backslash \bigcup_{m < n} E_m$, there are points $y,z \in A$
arbitrarily close to $x$ with $|f(y) - f(z)| > 3^{-n-1}$.