Hi,

I am trying to find my way around clojure and leiningen. I created a project 
with lein new, and up to now, all my code is in the src/../core.clj file

I have a function that defines functions based on what is read in from a 
csv-file, in the following format:

(defn define-all-properties
  []
  (for [ stuff ]
    ...
    (eval `(defn ~name [arg#]
              (...))))))

I then do

(define-all-properties)

Here is my problem: I have also tried to define in the same file functions 
based on those created by *define-all-properties*, like the following:

(defn obstruent? [sound]
  (or (stop? sound)
      (fricative? sound)))

When I load the core file for the first time, there is an error message, 
because the function stop? is not yet defined. I understand - I think - why 
this is so. After loading the core file for the first time, I have to 
evaluate (define-all-properties), and at the next load for the file, there 
is no error anymore.

While I can do that by hand with nrepl, the problem is that when I define 
tests in the tests directory, "lein test" also fails with the same error 
message.

I assume that making a makro out of *define-all-properties* is not the way 
to go, because it depends on the reading of a file, which should not yet be 
done at compile time (this may be a false assumption; in any way, simply 
changing the defn to a defmacro does not seem to resolve the issue).

Is there a (recommended) way of enforcing that a certain function has 
already been evaluated  when another one is called?

I thought I might try to create another file containing the function-
defining function, and then load it from the core file. It would be easier 
if in Leiningen, this could be specified (but I didn't find any reference to 
load order). 

Or is there a way of adding a hook to a function, specifying at which time 
it needs to be defined?

I hope that I am being clear here...

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to