I’m interested in using/overloading the “range step” operator (.. ..), but I can’t for the life of me find out how to use it.
In the documentation it says
// Usage:
start .. step .. finish
but trying that in the F# shell gives errors:
> let x = 1 .. 2 .. 7;;
let x = 1 .. 2 .. 7;;
----------^^
stdin(54,11): error FS0010: Unexpected symbol '..' in binding. Expected incomplete structured construct at or before this point or other token.
However, calling it “explicitly” is possible:
> let x = (.. ..) 1 2 7;;
val x : seq<int>
Is it only possible to use this operator for list/seq construction such as [1..2..7] and seq {1..2..7}?
The spec § 6.3.12 isn’t explicit about it, but the only examples given are within sequence expressions. That, along with the fact that nothing else works, seems to confirm your conclusion.
FYI – Here are the relevant docs for the range operators.
Operators.( .. )<^T>Operators.( .. .. )<^T,^Step>Section 3.8.2 also mentions special handling of
(.. ..), so it’s safe to assume it’s subject to limitations/behavior apart from those of typical functions/operators.