19

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?

A. Donda
  • 8,381
  • 2
  • 20
  • 49
Felipe
  • 16,649
  • 11
  • 68
  • 92
  • 3
    There's a nice blog post on the 'ungoogleable' characters of clojure here - there's a few of them! http://yobriefca.se/blog/2014/05/19/the-weird-and-wonderful-characters-of-clojure/ – Daniel Neal Jul 08 '14 at 08:31
  • Nice found! Good one. – Felipe Jul 18 '14 at 04:00

3 Answers3

14

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

Ben Kamphaus
  • 1,655
  • 10
  • 13
9

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 ;-)

peter_the_oak
  • 3,529
  • 3
  • 23
  • 37
  • https://www.google.com/search?q=%22Clojure+at+sign%22 3 results! :) And https://www.google.com/search?q=Clojure+%22at+sign%22 return THIS question!! :) – Felipe Jul 07 '14 at 22:19
  • 1
    One more good approach is to seek for a Clojure tut on one single html page, then ctrl-f to search the page content with the browser, and enter the @. This also brings some results. (Just as addendum as it really is sometimes diffucult to search for signs.) – peter_the_oak Jul 07 '14 at 22:28
  • 1
    One small nitpick: `#` is the generic reader-macro prefix, most reader evaluators start with #, including sets, anonymous functions, regex, timestamps, and any user defined records. `#` never introduces a hash-map, `#{}` is the notation for a set literal. – noisesmith Jul 08 '14 at 01:25
  • This page gives a reference for most of the ungoogleable characters: https://clojure.org/guides/weird_characters It does sort of assume a degree in CS though. – Tom Jun 15 '23 at 11:26
2

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.

mac
  • 9,885
  • 4
  • 36
  • 51