PROPOSAL: Binary Literals

Mark Thornton mthornton at
Thu Mar 26 01:54:26 PDT 2009

Derek Foster wrote:
> You are not considering the impact of constant folding on compiler optimizations.
> Not all constants are created equal. Constants whose values can be determined at compile time can be inlined by the compiler, and arithmetic expressions involving them can often therefore be simplified at compile time. This process is known as "constant folding". The resulting code need not reference the original variable to get the constant at all -- it can just use the inlined result of evaluating the expression. Additional compiler optimizations may then be performed on the basis of these folded constants. For instance, a compiler might decide to compile this code:
Perhaps you missed my suggestion that the range of operations permitted 
in constant expressions be extended to include the bit munging 
operations (and possibly others). We could perhaps have an annotation 
that was only permitted on static methods in the java.* name space and 
which required the compiler to execute the method at compile time if its 
arguments were compile time constants. The compiler could alternatively 
have a private list of such methods, the annotation conveniently tells 
everyone else what is on the list.

Mark Thornton

More information about the coin-dev mailing list