Confusion on the definition of regular function on projective space in Hartshorne I am reading morphism in Hartshorne and his comment confuses me. Firstly, he defines regular function on the affine space as follows:

Let $Y$ be a quasi-affine variety in $\mathbf{A}^{n}$. A function $f:Y\longrightarrow k$ is regular at a point $P\in Y$ if there is an open neighborhood $U$ with $P\in U\subseteq Y$ and polynomials $g,h\in A:=k[x_{1},\cdots,x_{n}]$ such that $h$ is nowhere zero on $U$, and $f=g/h$ on $U$.

Then, he commented as follows: "Here of course we interpret the polynomials as functions on $\mathbf{A}^{n}$, hence on $Y$. " Ok, I understand what he means here, because for each $f\in k[x_{1},\cdots, x_{n}]$, it can be considered as a function from $\mathbf{A}^{n}$ to $k$ by defining $f(P):=f(a_{1},\cdots, a_{n})$ for any $P:=(a_{1},\cdots, a_{n})\in\mathbf{A}^{n}$. So basically he wants to remind me that polynomials are also functions on $\mathbf{A}^{n}$.

Then, he defines regular function on the projective space as follows.

Let $Y$ be a quasi-projecitve variety in $\mathbf{P}^{n}$. A function $f:Y\longrightarrow k$ is regular at a point $P\in Y$ if there is an open neighborhood $U$ with $P\in U\subseteq Y$ and polynomials $g,h\in S:=k[x_{0},\cdots,x_{n}]$ such that $h$ is nowhere zero on $U$, and $f=g/h$ on $U$.

However, he comments as follows: "note that in this case, even though $g$ and $h$ are not functions on $\mathbf{P}^{n}$, their quotient is a well-defined function whenever $h\neq 0$, since they are homogeneous of the same degree."
What does he mean here? $g$ and $h$ are homogeneous polynomials right? Homogeneous polynomial $g$ gives a function from $\mathbf{P}^{n}$ to $\{0,1\}$ by $f(P):=0$ if $f(a_{0},\cdots, a_{n})=0$ and $f(P):=1$ if $f(a_{0},\cdots, a_{n})\neq 0$. Right?
Then, why wouldn't they be functions on $\mathbf{P}^{n}$? Is there any specific definition of "function" assumed here?
Thank you!
 A: 
Homogeneous polynomial $g$ gives a function from $\mathbf{P}^{n}$ to $\{0,1\}$ by $f(P):=0$ if $f(a_{0},\cdots, a_{n})=0$ and $f(P):=1$ if $f(a_{0},\cdots, a_{n})\neq 0$. Right?

The function you've described makes perfect sense (and it's useful in that it allows us to define the vanishing locus of $f$), but in order to make it well-defined you had to mod out by scalar multiples in the codomain.  Regular functions are by definition always valued in $k$, not in $k/k^{\times} = \{0, 1\}$--regardless of whether we're talking about affine or projective varieties.
An example might help.  Consider $\mathbf P^2$ with projective coordinates $[x_0 : x_1 : x_2]$.  Clearly, the homogeneous polynomial $x_0$ does not give a well-defined function $\mathbf P^2 \to k$, because for example the coordinates $[1 : 0 : 0]$ and $[2 : 0 : 0]$ represent the same point but have different values of $x_0$.  But I claim that $f = \frac{x_1}{x_0}$ does give a well-defined function to $k$, at least on the locus $U \subset \mathbf P^2$ where $x_0 \neq 0$.  The reason is simple:  if you scale coordinates by a nonzero constant $c$, then
$$
f([c x_0 : c x_1 : c x_2]) = \frac{c x_1}{c x_0} = \frac{x_1}{x_0} = f([x_0 : x_1 : x_2]).
$$
The same is true for $\frac{g}{h}$ whenever $g$ and $h$ are homogeneous polynomials of the same degree.
