F# supports references, allowing you to pass mutable values within your program. Let’s explore how references work in contrast to values with two functions: zeroval and zeroptr.
zeroval doesn’t change the i in main, but zeroptr does because it has a reference to the memory location for that variable.
To run the program, save it as References.fs and use the F# compiler:
Note that F# uses the term “reference” instead of “pointer”. The ref keyword creates a reference, and the ! operator dereferences it. The .Value property is used to get or set the value of a reference.
Also, F# doesn’t allow direct manipulation of memory addresses like in some other languages. Instead, it provides a safer, more abstract way of working with references.