4 ms·
Assuming you mean this: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives/preprocessor-if https://docs.microsoft.com/en-
by rwmj 6y ago
Assuming you mean this: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives/preprocessor-if https://docs.microsoft.com/en-us/dotnet/csharp/language-refe... it looks like a restricted form of the C preprocessor. (We may quibble about whether it is separately "pre" processed or not, but even cpp doesn't run as a separate stage in modern C compilers).
- pjmlp 6y agoThe C pre-processor doesn't have the monopoly on conditional compilation, it wasn't even the first language to support such features, they were already available in Algol variants and Macro Assemblers.
- rwmj 6y agoI'm not sure we're disagreeing. My point was that you need something separate from the language to deal with certain language compatibility issues.
- pjmlp 6y agoFair enough, but C is the snowflake here, in other languages conditional compilation is part of the language. Actually even in ISO C, the pre-processor is not required to be separated from the language, it is just kept that way in most compilers due to how C was originally implemented.
- Ididntdothis 6y agoThe C# preprocessor is unnecessarily restricted. It has a few features but it feels very arbitrary what they include or exclude. I think they didn’t like the idea but couldn’t avoid it totally so they did something half assed. I bet a lot of frameworks that need reflection could be replaced with macros if the preprocessor had a few more features.
- pjmlp 6y agoIt is not half assed, rather what has been proven since the 60's to work properly in all languages that aren't C, nor copy-paste compatible with C. Even C++ is reducing the need to keep using the pre-processor with each ISO revision, in an ideal modern C++ world without C legacy baggage, the pre-processor will be so half assed like in C#. C++20 is already almost there.