i have just started with Clojure. I am reading this. I did not understand the difference between how special forms are implemented and how functions and macros are implemented where it says
Nearly all functions and macros are implemented in Clojure source code. The differences between functions and macros are explained later. Special forms are recognized by the Clojure compiler and not implemented in Clojure source code.
Can someone explain the difference between two things ? ( implemented in Clojure source code and not implemented in Clojure source code)
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.
Binding Forms (Destructuring) The simplest binding-form in Clojure is a symbol. However, Clojure also supports abstract structural binding called destructuring in let binding lists, fn parameter lists, and by extension any macro that expands into a let or fn .
Implemented in Clojure source code
The code for the particular feature/abstraction is implemented in clojure language itself i.e in .clj file.
Not implemented in clojure source code
It is implemented in Java code.
Check out the Clojure code on github and you will find that there is Java as well as clojure code.
perhaps a more useful, from my perspective, way of putting it would be:
special forms are the parts of the language that, if someon took them away from you, you would not be able to replace them, and would have to recover them by other means.
for example if someone removed cond you could write your own cond macro (it's just a wrapper around if. should someone remove if ... you would have to fork the language and put it back.
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