Is there CAS design wisdom regarding categorizing expressions?
For instance: a user types in the expression $X^2 + X + 1$. Would it be best to classify it as a member of $R[X]$ (for some $R$, yet to be determined)?
What about $e^{X^2 + X + 1}$? This is some expression that is usually interpreted as a function, but it could also be just an element of $R[e^{X^2}, e^{X}, e^{1}]$. And there are other interpretations.
So the question is, what would be a simple but reasonable way to parse expressions? Maybe there could be a general Expression class that stands for all expressions, and later that expression might be tied to a function name, or something.
I'm using the D language and want to have syntactic sugar support for things like $e^x$ in code. So I'm thinking that all objects will default to variables unless they're declared with const:
const C y; R x;
then
Function(R,R) $f = e^x$;
and
C z = $e^y$;
where Function(R,R) is a template trick in D and the above would mean $f: \mathbb{R} \rightarrow \mathbb{R} : x \mapsto e^x$ and of course e would be defined as a const R.
$z$ would just be a variable assigned some value since $e^y$ is a constant.
Or something like that. The syntactic sugar stops at some point in D, but it would be fracking awesome to use it as much as possible.
Then an interpreter program could be written to communicate with the CAS.