Conditional expectation function Consider the standard linear regression model given by 
$Y = XB + \varepsilon$. 
$E[Y\mid X] = XB$ if $E[\varepsilon \mid X] = 0$. 
We say that the conditional expectation function is a random variable because $X$ is a random variable. But in econometrics textbooks I also read "with non-stochastic regressors, or conditional on $X$..." When we condition on $X$ in $E[Y\mid X] = XB$, is $X$ constant or not? If it is, why is the conditional expectation function a random variable? 
$E[Y\mid X = x]$ would be constant not $E[Y\mid X]$, because in the latter we do not consider realisations of $X$ while in the former we do. So what do we mean by that "conditional on $X$ is treating $X$ as constant?
I paste one paragraph from the econometrics book: "If the regressors can be treated as nonstochastic, as they would be in an experimental situation in which the analyst chooses the values in X, then the sampling variance of the least squares estimator can be derived by treating X as a matrix of constants. Alternatively, we can allow X to be stochastic, do the analysis conditionally on the observed X, then consider averaging over X as we did in obtaining (4-6) from (4-5)."
I read this as follows. If X is treated as constant, then there is no need to condition on X. If X is treated as random, then do the derivations conditional on X. So conditioning on X does not mean that X is treated as constant. So does E[Y|X] mean that X is constant? No. X is random, and we just condition on the random X. Conditioning on X does not make X constant. Or am I missing something? 
 A: The two scenarios exist. From wiki:

Depending on the nature of the conditioning, the conditional expectation can be either a random variable itself or a fixed value.



*

*If the experimenter cannot control the values of $X$ (the majority of cases in observational studies), the conditional expectation is a random variable because it is a function of a random variable (i.e. $X$).

*If the experimenter can control the $X$, $\mathbb{E}(Y\mid X)$ is no longer a random variable because $X$ is known.
Notice being known is different from being observed, after all you can observe realisations of a random variable. This might help get a better grasp of these two cases.
A: You're correct to say that $E[Y|X]$ is a random variable while $E[Y|X=x]$ is just a constant, as you mentioned in your last paragraph. However, $E[Y|X]$ notationally means "Tell me the expectation of Y when you know X". Conditioned on X, given X etc. all mean the same. So, $X$ is treated as constant inside this expectation because, you pretend as if you have/know it, and the whole idea is based around that fact. In general, you really have your data matrix, $X$, and fit a regression model.
