For the code below, is the arrow a macro or just simple character in the function name? ( from here)
(defn file->map
[file]
;; TODO
)
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.
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.
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.
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->>
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