Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

arrow in function name in Clojure

Tags:

clojure

For the code below, is the arrow a macro or just simple character in the function name? ( from here)

(defn file->map
  [file]
  ;; TODO
)
like image 716
ahala Avatar asked Jan 17 '14 15:01

ahala


People also ask

What does arrow mean in Clojure?

It has no syntactic meaning. It is just part of the symbol name. In Lisps, the arrow -> (or even just '>') is often used to imply conversion of, or casting of, one type into another.

What are symbols in Clojure?

There may be some confusion here from the different usages of the term "symbol" in Common Lisp and in Clojure. 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.

What are macros in Clojure?

Clojure has a programmatic macro system which allows the compiler to be extended by user code. Macros can be used to define syntactic constructs which would require primitives or built-in support in other languages. Many core constructs of Clojure are not, in fact, primitives, but are normal macros.


1 Answers

The arrow is part of the function name. There is a function definition, isn't?

(defn file->map  [file]
  ;; TODO)

(defn) defines a function. In your REPL, type:

(doc defn) 

(source defn)

Even Clojure core code provides such names, such as cond->> , cond-> , as-> , some->>

like image 107
Chiron Avatar answered Oct 03 '22 11:10

Chiron