tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier ...@ice-sa.com>
Subject Re: [OT] Setting HTTP response headers caching for 1 year doesn't work
Date Sun, 16 Jan 2011 13:41:31 GMT
Ran Berenfeld wrote:
> well ...no... first evaluate, then assign. and constants are int by default.
> I think C/C++ would have the same problem...
> 
Maybe.  But then why does the fact of specifying just the first right-hand side constant 
in the calculation as a long, magically change the whole result into a long ?
(1000 * 60 * 60 * 24 * 365)  --> int
(1000L * 60 * 60 * 24 * 365) --> long

Note: my intention is not to start a rant or a flame on the way Java does things.
I suppose that the Java syntax rules describe this accurately.
But I find this unintuitive.
Specially since it appears that in your first formula, the result is overflowing at some 
point in the calculation, without even a warning (?).

If someone writes
Long a = something
then someone clearly expresses the desire to obtain a Long result.
And if for some obscure reason that was really not the case, one could always write
Long a = (int) something

I suppose that there must be some implacable logic in the way it's done now, other than 
the evil intention to fool the unsuspecting programmer, but I honestly fail to see it.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message