Compile-time assertion?

Yes. You can do this with template specializations on type bool, like this: // empty default template template <bool b> struct StaticAssert {}; // template specialized on true template <> struct StaticAssert<true> { static void assert() {} }; int f() { StaticAssert<1==1>::assert(); // compiles fine, assert() member found StaticAssert<1==2>::assert(); // compile failure, no assert() member … Read more

Haskell GHC: what is the time complexity of a pattern match with N constructors?

A jump table is used, making the pattern-match a constant time operation. Unfortunately I’m unable to find an up-to-date citation for this, although this page mentions the implementation of Cmm-level switch statements as jump tables, and this old tagging design document uses a case on a Bool as an example, producing a jump table.

Python distutils, how to get a compiler that is going to be used?

This is an expanded version of Luper Rouch’s answer that worked for me to get an openmp extension to compile using both mingw and msvc on windows. After subclassing build_ext you need to pass it to setup.py in the cmdclass arg. By subclassing build_extensions instead of finalize_options you’ll have the actual compiler object to look … Read more

Will the compiler only compile code that can get executed?

No, the compiler includes the “dead” code as well. A simple reason for this is that it’s not always possible to know exactly what code will and won’t be executed. For example, even a private method that is never referenced could be called via reflection, and public methods could be referenced by external assemblies. You … Read more

Non-final methods in a final class

You’re correct, all methods in a final class are implicitly final. See here: “Note that you can also declare an entire class final. A class that is declared final cannot be subclassed. This is particularly useful, for example, when creating an immutable class like the String class.” And here: All methods in a final class … Read more

Why is the binary output not equal when compiling again?

ANOTHER UPDATE: Since 2015 the compiler team has been making an effort to get sources of non-determinism out of the compiler toolchain, so that identical inputs really do produce identical outputs. See the “Concept-determinism” tag on the Roslyn github for more details. UPDATE: This question was the subject of my blog in May 2012. Thanks … Read more