How exactly can we ensure that integers are printed in that way without using 2 separate data types? Isn't it possible for an integer stored as float to have imprecision?
Furthermore, since the arguments passed to print could be an expression, wouldn't doing this using an if condition and nearbyint() in the c code generated require dynamic memory allocation?
for example, a print statement can be as follows, since example 5 allows for addition in print statements.
print count + count * count - count * count * x
A c representation that properly checks if this is an integer or float would need to generate code that looks like
if (nearbyint(count + count * count - count * count * x) == count + count * count - count * count * x) {
print("%.0lf\n", count + count * count - count * count * x);
} else {
print("%.6lf\n", count + count * count - count * count * x);
}
to check whether the result of the expression is an integer
We would need to store the entire expression of count + count * count - count * count
as a string and substitute it into the code generated, which can only be done with dynamic memory allocation, since the expression isn't guaranteed to have a maximum length.