Re: require library from inside the REPL

2013-12-18 Thread Nicholas Wieland
Damn, you are right :)
Still, it's no good, and I don't understand why...

user=> (require '[theshire.models.element :as model])

Exception lib names inside prefix lists must not contain periods
 clojure.core/load-lib (core.clj:5359)


  ngw




On Wed, Dec 18, 2013 at 3:21 PM, Thomas Heller  wrote:

> The (:require ...) form is specific to the (ns) macro, in the REPL you'd
> invoke the require function directly.
>
> (require '[theshire.models.element :as model])
>
> HTH,
> /thomas
>
>
> On Wednesday, December 18, 2013 3:14:14 PM UTC+1, Nicholas Wieland wrote:
>>
>> https://gist.github.com/ngw/f8ef003532c8d712dd9b
>> I'm having troubles using the create function from inside the REPL.
>>
>> I think I should require it directly without defining a ns, right?
>>
>> user=> (:require [theshire.models.element :as model])
>>
>> CompilerException java.lang.ClassNotFoundException:
>> theshire.models.element, compiling/private/var/folders/r_/
>> 8jpc8nbx6x1g6gq3r1djmr90gp/T/form-init3432138121469073363.clj:1:1)
>>
>> what am I doing wrong?
>>
>>
>> TIA,
>>
>>   ngw
>>
>  --
> --
> 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.
>

-- 
-- 
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.


require library from inside the REPL

2013-12-18 Thread Nicholas Wieland
https://gist.github.com/ngw/f8ef003532c8d712dd9b
I'm having troubles using the create function from inside the REPL.

I think I should require it directly without defining a ns, right?

user=> (:require [theshire.models.element :as model])

CompilerException java.lang.ClassNotFoundException:
theshire.models.element,
compiling/private/var/folders/r_/8jpc8nbx6x1g6gq3r1djmr90gp/T/form-init3432138121469073363.clj:1:1)

what am I doing wrong?


TIA,

  ngw

-- 
-- 
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.


Re: requiring files

2010-12-29 Thread Nicholas Wieland

On Dec 29, 2010, at 5:14 PM, Eric Lavigne wrote:

> Hi, Nicholas.
> 
> I would need to see more detail in order to know what is going wrong
> in your case. I created a new project myself so that you can see an
> example that does work.
> 
> First I typed this:
> 
>lein new hello
> 
> That created a project in the hello directory. I changed in that
> directory and edited the file src\hello\core.clj (backslashes because
> I am working on Windows, but that isn't a big difference).
> 
>cd hello
>write src\hello\core.clj
> 
> I edited that file to look like this (added an example function).
> 
>(ns hello.core)
> 
>(defn say-hello [name]
>(println "Hello, " name))
> 
> After saving that file, I started a REPL to test it out.
> 
>lein repl
>(use 'hello.core)
>(say-hello "Nicholas")
> 
> And the REPL responded with:
> 
>Hello, Nicholas
>nil
> 
> It printed out the statement, as I told it to, and showed the return
> value of my function: nil.
> 
> Note the single-quote in (use 'hello.core) which is a little different
> from how the same thing would look as part of the ns macro.
> 
> Let me know if you have any more questions about this.

I've tried the same, but not in core.clj, but in another file named hello.clj:

(ns kenji.hello )

(defn hi [name]
(println "HI " name))

Then I go to the REPL and I try:

[...@slicingupeyeballs:~/kenji]$ lein repl(12-29 23:26)
REPL started; server listening on localhost:21669.
kenji.core=> (:require 'kenji.hello)
nil
kenji.core=> (hi "nick")
java.lang.Exception: Unable to resolve symbol: hi in this context 
(NO_SOURCE_FILE:2)

[...@slicingupeyeballs:~/kenji]$ ls -l src/kenji  (12-29 23:31)
total 24
-rw-r--r--@ 1 ngw  staff   244 Dec 29 16:24 core.clj
-rw-r--r--@ 1 ngw  staff  5756 Dec 29 23:26 hello.clj

Stuff in core.clj works normally, no problem at all.

TIA,
  ngw

-- 
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


Re: requiring files

2010-12-29 Thread Nicholas Wieland
On Dec 29, 2010, at 5:21 PM, Laurent PETIT wrote:

> Hello,
> 
> I've added an entry to this in the FAQ, under the "Namespaces" section : 
> 
> http://dev.clojure.org/display/doc/FAQ

Thank you. My "project-name" anyway was just a placeholder, my namespace 
doesn't have any underscore in it :)

Sorry for the confusion,
  ngw

-- 
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

requiring files

2010-12-29 Thread Nicholas Wieland
Hi *,
I'm a bit ashamed but considering that I'm a newbie in Clojure and a total 
newbie in Java there's apparently no end to this metanewbie status I'm 
currently in :-)
I'm trying to require a file and use it from the REPL, but every time I try to 
call a function from this file Clojure is not able to resolve the symbol.
What I did is creating a project using lein, and lein created a directory 
structure that includes src/project_name, where I believe I'm supposed to put 
my files.
Now, other than the canonical core.clj I've created another file foo.clj. 
There's still no interaction between the 2 files, but just as a matter of 
testing what I'm writing I would like to be able to call the functions of 
foo.clj from the REPL. The namespace is declared to be project_name.foo.
I've tried to use both require and use inside lein repl, no matter what I do it 
doesn't find the file (NO_SOURCE_FILE). If I understand the functioning right 
I'm supposed to only use the namespace, so (:require project_name.foo) should 
actually work and include the full namespace (that I translate mentally with 
"file" :) inside the current one, that according to the repl is 
project_name.core.
Someone has a suggestion on where to look or how to fix ?

  ngw

-- 
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