Lesson 11. Naming stuff with def

 

Naming things is one of the most basic and deepest ability of the human kind. According to the Bible, the first man (Adam)  started to give name to the creatures around him even before other men were created.

“Now the Lord God had formed out of the ground all the wild animals and all the birds in the sky. He brought them to the man to see what he would name them; and whatever the man called each living creature, that was its name. So the man gave names to all the livestock, the birds in the sky and all the wild animals.” (Genesis, Chapter 2)

Naming is not only a spiritual or a communication skill. It is also very useful in the context of software programming. Well, one can say that software programming is about communication between men and machines making this mind related activity highly spiritual.

Anyway, any programming language offers ways to name things and to refer things by their names. Giving a name is usually called variable assignment and it looks like this is pseudocode:

my-variable = my-value

In some statically typed languages like java or C#, one has also to specify the type of the variable to be assigned. Clojure, being a dynamically type language, doesn’t require the developer to specify the type of the variable.

In Clojure, the entity that has a name and holds a value is called var - a shorthand for variable.  The cool things with Clojure vars are that:

11.1   def syntax

11.2   naming rules and conventions

11.3   dynamically typed language

11.4   Summary