Closed Thorium closed 3 weeks ago
I think this is a reasonable suggestion, can you copy this over to https://github.com/fsharp/fslang-suggestions? It is where suggestions go and can be upvoted. It is used for suggestions that require a language, core lib or syntax change. If accepted by Don, we will then proceed with an RFC and, hopefully, an implementation.
Note that there's some prior discussion here: https://github.com/fsharp/fslang-suggestions/issues/273 (if you look at the archived comments, you can see that that was still from the F# 4 days in Codeplex. The design of the time is gone, but clearly, the part that says #elif
didn't make it into the language at the time).
edit, note that #if
can be nested, so your code example may be easier if turned into this:
let myPath =
#if WIN64
"/library/x64/runtime.dll"
#else
#if WIN86
"/library/x86/runtime.dll"
#else
#if MAC
"/library/iOS/runtime-osx.dll"
#else
"/library/unix/runtime.dll"
#endif
#endif
#endif
(I mean, it would be easier to read with your suggestion, but at least you won't need the complex boolean expressions)
Closing this, as it is now here: https://github.com/fsharp/fslang-suggestions/issues/1370
F# seems to have
#elif
preprocessor directive / pragma missing: https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/compiler-directives#preprocessor-directivesC# has it: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives#conditional-compilation
I know it's not good practice to use lot of these, I'm not trying to do a templating engine, I would just like to do a simple switch like this:
The current workaround: