Fork me on GitHub
#beginners
<
2015-09-14
>
mosho07:09:56

How can I have a namespace spanning multiple files in a folder?

ecelis07:09:22

add (ns somehing.core)

ecelis07:09:38

of course, replace something core for your namespace

mosho07:09:20

yeah, but if I try to have two files with the same ns declaration it doesn't seem to work

ecelis07:09:42

too late to look into that,

surreal.analysis12:09:17

@mosho: are you using Clojure or ClojureScript?

surreal.analysis12:09:43

Which makes use of in-ns instead of ns in the helper classes, and load to load the helper classes in the main file

roberto14:09:59

@mosho that is not recommended. There were discussions about that on the clojure channel.

mosho19:09:57

@surreal.analysis: yeah, I saw that, but I'm using cljs

surreal.analysis19:09:02

Out of curiosity, why are you trying to split namespaces across files?

surreal.analysis19:09:34

It generally seems like it is not the recommended way unless you are creating a large standard library (e.g. clojure.core)

mosho19:09:49

to not have a big file for the entire namespace

mosho19:09:04

I don't think that is something the programming language should dictate

mosho19:09:12

it's a fairly common practice

rauh19:09:39

I think people use potemkin for that

mosho19:09:00

in my case, I have several components that make up a page, and would like them to each be in its own file, but having one namespace to hold them. like "my.project.components" seems like the right idea

mosho19:09:27

instead of "my.project.componentX"

mosho19:09:44

so I don't have to refer to each separate one

ecelis19:09:34

Tha seems a very Java way of organizing code, no criticism intended, I also like to split code like that

ecelis19:09:46

But I haven't to do that in clojure until now

mosho19:09:47

We started doing that (kinda) in JS when we moved to ES6

mosho19:09:05

Why do you not feel the need in clojure?

roberto20:09:20

spreading a ns across multiple files, in Clojure, is like spreading the definition of a Class in Java, across multiple files.

roberto20:09:40

think of a ns in clojure as a static class in Java. At least that is how I think of it.