Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikibooksThe Free Textbook Project
Search

Clojure Programming/Examples/API Examples/Reference Tools

From Wikibooks, open books for an open world
<Clojure Programming |Examples |API Examples

ref

[edit |edit source]

Seeref-set for more.

user=>(defcross-thread-mutable(ref{}))#'user/cross-thread-mutableuser=>cross-thread-mutable#<Refclojure.lang.Ref@1a5f739>user=>

ref-set

[edit |edit source]
user=> (def foo (ref 0)) #'user/foo user=> foo #<Ref clojure.lang.Ref@7c2479a4> user=> @foo 0 user=> (ref-set foo 1) java.lang.IllegalStateException: No transaction running (NO_SOURCE_FILE:0) user=> (dosync (ref-set foo 1)) 1 user=> @foo 1

deref

[edit |edit source]

@

[edit |edit source]
(deref (ref 5))@(ref 5)@(atom 5)(with-local-vars [x 5] @x)@(agent 5)

delay

[edit |edit source]

force

[edit |edit source]
(def df (delay (println "hello")))(println "world")--> world(force df)--> hello

commute

[edit |edit source]
(def employee-records (ref #{}))(dosync (commute employee-records conj "employee"))
Retrieved from "https://en.wikibooks.org/w/index.php?title=Clojure_Programming/Examples/API_Examples/Reference_Tools&oldid=3679391"
Category:

[8]ページ先頭

©2009-2025 Movatter.jp