Meaning of confusing comment above “string.Empty” in .NET/BCL source?

The important part is not what happens IN this class, but what happens, when another class uses (and links to) it. Let me explain with another example: Assume you have a Assembly1.dll containing a class declaring public static const int SOME_ERROR_CODE=0x10; public static readonly int SOME_OTHER_ERROR_CODE=0x20; and another class consuming this e.g. public int TryFoo() … Read more

Should I still use #include guards AND #pragma once?

It depends on how much portable your program is expected to be. As long as you are writing a program which is supposed to work with compilers which you know definitely support #prama once, just using #pragma once should suffice. But doing so you restrict your program to set of compilers which support the implementation … Read more

How to check if C++ compiler uses IEEE 754 floating point standard

Actually you have an easier way to achieve this in C++. From the C++ standard 18.2.1.1 the class numeric_limits exists within std. In order to access said static member you simply do this: std::numeric_limits<double>::is_iec559; Or: std::numeric_limits<float>::is_iec559; Which should return true if IEEE 754 is in use, false otherwise. As an alternative method, the second part … Read more

Why does autoboxing make some calls ambiguous in Java?

When you cast the first argument to Object yourself, the compiler will match the method without using autoboxing (JLS3 15.12.2): The first phase (ยง15.12.2.2) performs overload resolution without permitting boxing or unboxing conversion, or the use of variable arity method invocation. If no applicable method is found during this phase then processing continues to the … Read more

C# compiler bug? Why doesn’t this implicit user-defined conversion compile?

Apparently, implicit user defined conversions don’t work when one of the types is an interface. From the C# specs: 6.4.1 Permitted user-defined conversions C# permits only certain user-defined conversions to be declared. In particular, it is not possible to redefine an already existing implicit or explicit conversion. For a given source type S and target … Read more

How to tell if a binary is release or debug in both win and *nix

for C++ on Linux, you can do: objdump –source yourbin |grep printf Replace printf with whatever function call you do. If it is debug, it will display all the actual source code call you do. If it is release, it will just display the founded symbol from the symbol table. for C++ on Windows, you … Read more

How does the Erlang compiler implement pattern matching?

A very good description of compiling pattern matching is given in “The implementation of functional programming languages” by Simon Peyton Jones. It is a bit old but a very good book. It also contains, amongst other things, a description of compiling list comprehensions. The Erlang compiler uses both of these algorithms from the book.