Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of core.clj file?

Tags:

clojure

I am just started on clojure and have a very basic question about core.clj.

What is a convention about it? What code should go there? Public API?

It is generated by leiningen when creating a project. I have looked into source code of some libraries and this file is also present there (per package?).

Thanks

like image 931
Vasyl Keretsman Avatar asked Feb 07 '14 07:02

Vasyl Keretsman


People also ask

How do I start Clojure REPL?

To start a REPL session in Eclipse, click the Menu option, go to Run As → Clojure Application. This will start a new REPL session in a separate window along with the console output.


2 Answers

There's no defined meaning for it, but in an application it's often where you'll find the entry point, the main- function. For libraries, foo.core is often the namespace users will import to get your main functionality.

You don't have to do it that way, but it's a semi-predictable place to have the 'central bit' of whatever it is you're writing - even if your actual logic and algorithmic code is somewhere else.

like image 194
Matthew Walton Avatar answered Oct 21 '22 06:10

Matthew Walton


Leiningen generates foo.core because it needs to pick a name and core is generic enough that it probably wont' be wrong. It's a style decision, but I typically opt to rename core.clj to a name that is actually meaningful for my project.

like image 8
noisesmith Avatar answered Oct 21 '22 06:10

noisesmith