On 7/9/2011 2:58 AM, rop rop wrote:
I also think not, in the general case...
But you could also have an annotation argument, like
@CheckForOverflow(allTheWayDown=true)
or
@CheckForOverflow(allTheWayDown=false)
I did a quick check of the C# variant when it was mentioned here, and
this is how they do it:
int result = checked( a + b - c );
In other words is a key word. Since Java can't really do this easily,
I'd be in favor of using an existing key word and extending it. For
example, the key word "try" can't ever appear currently as a class name
or package name in any program, so we could do this:
int result = try.checked( a + b - c );
Which at least makes sense to me as one reads the code; i.e., it's
literate programming. One could, I suppose, also extend the syntax where
an annotation can be used, but this might have side effects also. For
example, it might be hard to support these new user defined annotations
in the general case.