We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider this horribly imperative program:
type C() = let mutable nums = [| 1; 3; 7; 15; 31; 63; 127; 255; 511; 1023 |] override __.ToString() = String.Join(' ', nums) member __.FindLargestSmaller(target: int) = let mutable ctr = nums.Length - 1 while ctr > 0 && nums.[ctr] >= target do ctr <- ctr - 1 if ctr > 0 then &nums.[ctr] else &nums.[0] [<EntryPoint>] let main argv = let c = C() printfn "Original sequence: %s" (c.ToString()) let num = 16 let v = &c.FindLargestSmaller(num) v <- v*2 printfn "New sequence: %s" (c.ToString()) 0 // return an integer exit code // Gives: // Original sequence: 1 3 7 15 31 63 127 255 511 1023 // New sequence: 1 3 7 30 31 63 127 255 511 1023
Note that v is not mutable - it doesn't need to be, since it's a pointer.
v
mutable
Except it's not colored as if it could be mutated like that.
The text was updated successfully, but these errors were encountered:
Note that you cannot assign to an inref:
inref
let f1 (x: inref<int>) = x <- 1
So even though it's not the same thing as mutability, since you can only read the value, it's fine if it's not colored.
Sorry, something went wrong.
No branches or pull requests
Consider this horribly imperative program:
Note that
v
is notmutable
- it doesn't need to be, since it's a pointer.Except it's not colored as if it could be mutated like that.
The text was updated successfully, but these errors were encountered: