Mutable vs Ref in terms of capture

My superficial understanding of variables in f # suggests that declaring a variable is "mutable" and using the variable "ref" essentially does the same. Both of them are different ways to solve the same main problem - a limited and structured accounting for variability in a functional language without the need to resort to IO Monad. In my understanding, the “technical” was “abstracted”.

  • If so, why can't you capture exciting variables, but can they capture ref instances?
  • More generally, what is the technical difference between the two forms that allow this difference?
  • What is the goal in terms of language design with the representation of two abbreviations with a change, and not just one?

I apologize if this is a multi-starter, but they all seem interconnected.

+7
closures f # mutability
source share
1 answer

Cm.

http://lorgonblog.wordpress.com/2008/11/12/on-lambdas-capture-and-mutability/

especially in the “comment on language design” section (I would quote it here, but it’s not alone, you need the entire blog post for context).

+6
source share

All Articles