Let me preface this by saying that this is not a huge deal; it’s just something that happens in code sometimes that is currently annoying. But it only happens every once in a while.
Just to clarify: The “annoying thing” that I’m talking about is not that there are warnings sometimes. The annoying thing to me is that if I’m not careful I could be getting the wrong answer if Stan is rounding or truncating things.
The original place where this tripped me up was when I had this code:
L = sqrt(1/sigma[n]^2 + 1/tau^2);
and I got a warning in compilation.
Seeing a warning in compilation is not such a big deal; in this case I changed the "1"s to "1."s and then it worked. The code is now slightly uglier, but no big deal.
Even better in my opinion would be for Stan to convert to reals. I’d like 1/sigma^2 not to truncate or round or whatever it does. Similarly, if I type 1/3 in Stan I’d like it to be the number 0.3333333etc, not 0. That is, doing x/y will return a real number if x and y are integers or reals. If you want integer division, you can do round(x/y) or floor(x/y) or int(y/x) whatever.
But I guess that’s a matter of taste. If other people want 1/sigma^2 to truncate and 1/3 to be 0, then that’s the way it is. In that case, I would like Stan to return that warning, as otherwise I think I won’t be the only user to enter code like 1/sigma^2 and 1/3 and get the wrong answer.
I think it would be a problem for Stan to not give a warning when it truncates or rounds things like 1/sigma^2 or 1/3.
Also, as a user, I don’t recommend adding a real_divide function: (a) that’s one more function, and we have a lot of functions to keep track of already, (b) I don’t think this helps for users. From my “user” perspective, the problem is that sometimes in Stan you need to convert an integer to a real number, just like sometimes you have to convert a vector to an array or an array to a vector. If I had two integers, i and j, and I want i/j, and if Stan won’t convert these to reals automatically, then I’d just as soon do real(i)/real(j), as that would be clearer than a real_divide function.