wisp-lang / wisp

A little Clojure-like LISP in JavaScript
https://gozala.github.io/wisp/
Other
982 stars 68 forks source link

Local module imports not working #125

Closed danieltanfh95 closed 9 years ago

danieltanfh95 commented 9 years ago

I have two wisp modules, app.wisp and random.wisp. The goal is to import random.wisp into app.wisp. Is there an idiomatic way to do this?

using (:require [random]) or (:require [random.wisp]) does not work as wisp does not recognisethe namespace, for the former, and for the latter it will turn random.wisp to random/wisp.

danieltanfh95 commented 9 years ago

Apparently it was a problem with my namespace naming. naming the namespace to rainbow.app and rainbow.random before calling

(ns rainbow.app
  (:require [rainbow.random]))

works.

robjens commented 9 years ago

Right. I had the same. Normal convention in Clojure e.g.

src/core/{submodule_a.clj, submodule_b.clj}
src/core.clj # consolidate submodule either doing (load ..) and (in-ns ..) or by delegate fns etc

Then one can do (:require (example.core [submodule-a :as a] [submodule-b :as b]...)) This form doesn't work in Wisp (although it could be, and rather should since managing these should perhaps just enforce the proper directory structure and could throw specifically on incorrect named/missing directories).

Anyway I could use example.core.submodule executed by wisp, and use either as dependencies anywhere, except when trying to refer to core.wisp from example.core.submodule, THEN it would break complaining about some . missing (./) while it would need to ../core.wisp.