User Carsten has provided the following comment to this answer as he considers it to be wrong.
the thing is: when
used as is here has nothing to do with the
documented usages - it seems to be called static conditional
optimization and should not be used outside the core libraries -
indeed go on and try to use it - you will see that you cannot unless
you use the tricks mentioned in Johns answer (other question)
User Carsten added an additional comment to this answer:
I added a comment - I don't think my educated guess is worth an answer
- I hoped that one of the insiders hanging around would finally put an official answer to it
The answer referred to in Carsten's first comment is by user John Palmer in April 2013 which links to this answer he provided on the (# ..... #)
syntax, What is the (# ... #) syntax seen in F3 standard library implementation?
You can actually use this but you have to specify the
--compiling-fslib
(undocumented) and --standalone
flags in your code.
User MisterMetaphor provided an answer quoting a posting in a forum that said the following:
Embedded IL in F# codes. Is this feature officially supported?
Not really. The 99.9% purpose of this feature is for operations
defined in FSharp.Core.dll (called fslib.dll in 1.9.2.9 and before).
For other uses of the when
keyword see the following.
This Microsoft document describes using the when
keyword for additional conditions on matching, Match Expressions (F#).
This Microsoft document describes using the when
keyword to express constraints for generic type parameters, Constraints (F#).
Also see this Microsoft document describing pattern matching with the when
keyword in various settings, Pattern Matching (F#).
The Pattern Matching document says the following along with several examples.
Patterns are rules for transforming input data. They are used
throughout the F# language to compare data with a logical structure or
structures, decompose data into constituent parts, or extract
information from data in various ways.
The Match Expression document says the following along with an example.
You can use a when clause to specify an additional condition that the
variable must satisfy to match a pattern. Such a clause is referred to
as a guard. The expression following the when keyword is not evaluated
unless a match is made to the pattern associated with that guard.