How to use: fin?

In Clojure, Koans : fin is used in atom.clj. Here is one example:

(def atomic-clock (atom 0)) "Atomic atoms are atomic" (= 20 (do (compare-and-set! atomic-clock 100 :fin) @atomic-clock)) 

I understand that: fin is the new meaning. But why is it used instead of a number?

I was looking for documentation for: fin is used and cannot find its use except in Koans.

Thanks.

+4
source share
1 answer

In Clojure, the colon does something called a keyword, or a key:

 user=> (type :xyz) clojure.lang.Keyword 

Keys are used in cards because they are easy to check for equality and convert to strings. You can see that later in the same file :fin again used in equality checking:

 (= :fin (do (compare-and-set! __ __ __) @atomic-clock))) 
+8
source

Source: https://habr.com/ru/post/1379520/


All Articles