I found this line of Clojure code: @(d/transact conn schema-tx)
. It's a Datomic statement that creates a database schema. I couldn't find anything relevant on Google due to difficulties searching for characters like "@".
What does the 'at' sign mean before the first parenthesis?
In Common Lisp, a "symbol" is a location in memory, a place where data can be stored. The "value" of a symbol is the data stored at that location in memory. In Clojure, a "symbol" is just a name. It has no value.
It's a way to write code left to right, instead of inside out, e.g. (reduce (map (map xs bar) foo) baz) becomes (-> xs (map bar) (map foo) (reduce baz))
Clojure is a practical language that recognizes the occasional need to maintain a persistent reference to a changing value and provides 4 distinct mechanisms for doing so in a controlled manner - Vars, Refs, Agents and Atoms.
This is the deref macro character. What you're looking for in the context of Datomic is at:
http://docs.datomic.com/transactions.html
under Processing Transactions:
In Clojure, you can also use the deref method or @ to get a transaction's result.
For more on deref in Clojure, see:
http://clojuredocs.org/clojure_core/clojure.core/deref
Here is a useful overview of Clojure default syntax and "sugar" (i.e. macro definitions).
http://java.ociweb.com/mark/clojure/article.html#Overview
You'll find explained the number sign #
, which indicates regex or hash map, the caret ^
, which is for meta data, and among many more the "at sign" @
. It is a sugar form for dereferencing, which means you get the real value the reference is pointing to.
Clojure has three reference types: Refs, Atoms and Agents.
http://clojure-doc.org/articles/language/concurrency_and_parallelism.html#clojure-reference-types
Your term @(d/transact conn schema-tx)
seems to deliver a reference to an atom, and by the at sign @
you defer and thus get the value this reference points to.
BTW, you'll find results with search engines if you look e.g. for "Clojure at sign". But it needs some patience ;-)
The @ is equivalent to deref in Clojure. transact returns a future which you deref to get the result. deref/@ will block until the the transaction completes/aborts/times out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With