📅  最后修改于: 2020-11-05 04:07:10             🧑  作者: Mango
参考值是Clojure可以与需求一起使用的具有可变变量的另一种方式。 Clojure提供了可变的数据类型,例如原子,代理和引用类型。
以下是可用于参考值的操作。
Sr.No. | Operations & Description |
---|---|
1 | ref
This is used to create a reference value. When creating a reference value, there is an option to provide a validator function, which will validate the value created. |
2 | ref-set
This function is used to set the value of a reference to a new value irrespective of whatever is the older value. |
3 | alter
This function is used to alter the value of a reference type but in a safe manner. This is run in a thread, which cannot be accessed by another process. |
4 | dosync
Runs the expression (in an implicit do) in a transaction that encompasses expression and any nested calls. |
5 | commute
Commute is also used to change the value of a reference type just like alter and ref-set. |