Fsharp: Reference Type

By Xah Lee. Date: .

fsharp reference type

What is reference type in F sharp?

(ai answer)

A reference type is a type whose values are stored on the heap and accessed through a pointer. In F#, the main ones are classes, records, unions, arrays, lists, and strings.

Can you define the reference type in a more formal way without referring to heap? Because that relates to the hardware.

A reference type is a type whose values are accessed indirectly through a reference — a value that identifies another value rather than being the value itself. The reference is a first-class value: it can be stored in variables, passed to functions, and compared for identity. Two references can point to the same underlying value, so mutation through one is visible through the other.