Why doesn’t the C# compiler stop properties from referring to themselves?

You can see the “official” reason in the last comment here. Posted by Microsoft on 14/11/2008 at 19:52 Thanks for the suggestion for Visual Studio! You are right that we could easily detect property recursion, but we can’t guarantee that there is nothing useful being accomplished by the recursion. The body of the property could … Read more

Are modern C++ compilers able to avoid calling a const function twice under some conditions?

GCC has the pure attribute (used as __attribute__((pure))) for functions which tells the compiler that redundant calls can be eliminated. It’s used e.g. on strlen. I’m not aware of any compiler doing this automatically, especially considering the fact that the functions to be called may not be available in source form, and the object file … Read more

What happens to you if you break the monad laws?

The monad laws are simply additional rules that instances are expected to follow, beyond what can be expressed in the type system. Insofar as Monad expresses a programming pattern, the laws are part of that pattern. Such laws apply to other type classes as well: Monoid has very similar rules to Monad, and it’s generally … Read more

Is C++ platform dependent?

This is actually a relatively extensive topic. For simplicity, it comes down to two things: operating system and CPU architecture. First of all, *.exe is generally only Windows since it is binary code which the windows operating system knows how to execute. Furthermore, the operating system knows how to translate this to the proper code … Read more

Javascript parser generator [closed]

I recently wrote this parser combinator library called parsinator.js that supports state and debugging functionality: https://github.com/fresheneesz/parsinator.js Old Answer: PEG.js is incredibly easy to work with. Its “try online” feature is really useful in learning how to use the system quickly. I’m currently using it in the Rhino environment to parse a language I’m writing. I’m … Read more

Is there a more modern, OO version of “Let’s Build a Compiler”? [closed]

It sounds like you completely missed the point of Crenshaw’s tutorials. LBC isn’t about writing pretty, clean, or efficient code. It’s all about bringing something that’s steeped in formal theory down to a level where the casual coder can easily and rapidly hack out a rudimentary (but working!) compiler. When I read through LBC years … Read more

while(true); loop throws Unreachable code when isn’t in a void

The language spec has an exact definition what the compiler should treat as unreachable code, see also https://stackoverflow.com/a/20922409/14955. In particular, it does not care about if a method completes, and it does not look inside other methods. It won’t do more than that. However, you could get static code analysis tools like FindBugs to get … Read more