Skip to content

Instantly share code, notes, and snippets.

@realvictorprm
Created September 28, 2017 15:32
Show Gist options
  • Save realvictorprm/4642a90ce9538596720fbc0d9f5dd0e3 to your computer and use it in GitHub Desktop.
Save realvictorprm/4642a90ce9538596720fbc0d9f5dd0e3 to your computer and use it in GitHub Desktop.
Those cases here show when allocations happen without being want.
type WhoDesignedThisAnyway =
{ Field: string }
/// allocates two functions, and a tuple each time this is called.
static member Lens = (fun x -> x.Field), (fun v x -> {x with Field = v })
module WhoDesignedThisAnyway =
/// doesn't allocate
let Lens2 = (fun x -> x.Field), (fun v x -> {x with Field = v })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment