#clojure log - Jun 06 2009

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

7:59 alrex021: I am having a problem using the :use to import my functions from another clj file.

7:59 http://pastebin.com/ma22491

7:59 I get a Caused by: java.lang.Exception: Unable to resolve symbol: add-message in this context

8:10 Chousuke: alrex021: why do you have :gen-class in the concurrency namespace?

8:11 alrex021: Chousuke: Though it will then use the name of my file as the class name for compilation. If I take it out, it still gives me a same problem

8:13 Chousuke: alrex021: what command are you using to run your code?

8:14 alrex021: I am actually using the Enclojure in Netbeans which seems to generate the Java classes at compile time.

8:14 Chousuke: hm

8:15 it shouldn't really matter whether it's compiled or not.

8:15 alrex021: But the code seems fine? I'm not missing something obvious?

8:15 Chousuke: hmm

8:16 alrex021: Chousuke: I'm new to Clojure so am afraid I could very easily be doing something stupid

8:16 Chousuke: It seems fine. This is just a guess, but try changing the (:use (com.lunasoftworks.concurrency)) to (:use (com.lunasoftworks concurrency))

8:17 that way, it matches the doc string examples

8:17 alrex021: I am just truing to learn here to group a set of functions into their own file and then use the :use to load them

8:17 Chousuke: though the dotted form should work too :/

8:18 alrex021: Chousuke: well you no what, it worked

8:18 Chousuke: hmm :)

8:18 alrex021: skipping the last dot that is before concurrency

8:18 (:use (com.lunasoftworks concurrency))

8:18 interesting :)

8:18 Chousuke: the :use form works so that you can list multiple namespaces after the prefix.

8:19 (:use (clojure.contrib strutils2 sql monads)) like that

8:19 alrex021: Ahh, I have seen that

8:19 Chouser: perhaps (:use com.lunasoftworks.concurrency) would also work?

8:20 Chousuke: right.

8:20 try that :)

8:20 Chouser: ...using inner parens only with the dotted form?

8:20 clojurebot: ????? ????

8:20 alrex021: though whats funny is that I got get a syntax error or something similar at compile time complaining about my :use. ..

8:21 Chouser: oh ok, regarding your last line, let me give that a try..\

8:22 Ahhhh, you right. Dropping the parents when not specifying the multiple uses, works

8:22 So to confirm, this works too: (:use com.lunasoftworks.concurrency)

8:22 Chousuke: require's documentation is out of date :/

8:22 For example, the lib 'x.y.z has root directory <classpath>/x/y/z; root resource <classpath>/x/y/z/z.clj.

8:23 not true anymore :P

8:23 alrex021: Chousuke: In your opinion, which way would be recommended: (:use com.lunasoftworks.concurrency) OR (:use (com.lunasoftworks concurrency))

8:23 Chousuke: either is fine

8:24 use whichever you like :)

8:25 alrex021: gr8 :) thx Chousuke for your help

12:50 tayssir: Hi! Does anyone know a resource where I can learn why add-classpath isn't supposed to work on Emacs/Slime? (When I try it, it just returns nil and doesn't seem to update anything. I realize it's not considered good to use, but I can't find a page explaining why it should fail silently..)

12:58 dnolen: tayssir: add-classpath doesn't return a value, it returns nil.

13:59 Anniepoo: hmm.... I seem to have broken my La Clojure install. When I try to 'Edit configurations' I don't see any entries - Add Configuration I see two entries for Clojure Script. Setting up based on either one, then trying to run - just returns me to an Edit Configurations dialog.

14:05 Strange, adding a trivial Java class with a main and setting up a config for it fixes the problem. It then becomes possible to set up Clojure scripts normally

14:20 Drakeson`: 1) how can I make an alias for "clojure.contrib" to make it easier to load things? 2) Is it possible to have a :use at the top of the file in the ns form that pulls in some other libraries? (an [empty] meta "library")

14:21 kotarak: Drakeson`: (require '(clojure.contrib [def :as def] [duck-streams :as ds]))

14:21 Drakeson`: there are things like import-ns or so. But in general the answer to 2) is: no.

14:22 Drakeson`: kotarak: thanks

14:25 assume I run clojure by doing: java -cp all.jar clojure.main . Is it possible to ask such running instance of clojure to re-load all.jar (meanwhile, all.jar has possibly been changed on the disk)?

14:25 Anniepoo: anybody recognize this problem with La Clojure?

14:25 Language with ID 'Clojure' is already registered: class org.jetbrains.plugins.clojure.ClojureLanguage

14:25 java.lang.Throwable

14:25 at com.intellij.openapi.diagnostic.Logger.error(Logger.java:48)

14:25 at com.intellij.lang.Language.<init>(Language.java:70)

14:25 at com.intellij.lang.Language.<init>(Language.java:55)

14:25 clojurebot: clojure is the bestest programming language available.

14:25 Anniepoo: at com.intellij.lang.Language.<init>(Language.java:51)

14:25 at org.clojure.intellij.ClojureLanguage.<init>(ClojureLanguage.java:24)

14:25 at org.clojure.intellij.file.ClojureFileType.<init>(ClojureFileType.java:42)

14:25 at org.clojure.intellij.file.ClojureFileType.<clinit>(ClojureFileType.java:34)

14:25 at org.clojure.intellij.file.ClojureFileTypeLoader.createFileTypes(ClojureFileTypeLoader.java:23)

14:25 at com.intellij.openapi.fileTypes.impl.FileTypeManagerImpl.a(FileTypeManagerImpl.java:185)

14:26 at com.intellij.openapi.fileTypes.impl.FileTypeManagerImpl.<clinit>(FileTypeManagerImpl.java:333)

14:26 at java.lang.Class.forName0(Native Method)

14:26 at java.lang.Class.forName(Class.java:247)

14:26 kotarak: Anniepoo: please use a paste

14:26 lisppaste8: url

14:26 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

14:28 Anniepoo pasted "alreadyAClojure" at http://paste.lisp.org/display/81460

14:30 kotarak: Drakeson`: I don't think so. Jars cannot be reloaded AFAIK.

14:31 Drakeson`: kotarak: thanks. it is important to know.

14:33 kotarak: Drakeson`: there are things like Java Rebel, which reload classes. But I don't know how that works. And whether this includes a changed jar.

14:33 Anniepoo: maybe you installed a older version of the plugin?

14:34 And now the new one has a conflict with that?

14:34 Anniepoo: yes, good possibility

14:35 I removed a bunch of plugins I wasn't using, cause I was tired of the long startup time,

14:35 including the disabled 'clo jet' - might have been that?

14:36 Drakeson`: kotarak: I guess I think too pythony. In python I can place a new thing.py in the PATH and then ask the running instance to import thing.

14:36 kotarak: Drakeson`: you can do that with .clj files to. Then use eg. (require :reload ...) or (require :reload-all ...) to reload the .clj files.

14:37 Drakeson`: but that's limited to file system files. files in jars are different.

14:37 Anniepoo: no clue. I don't have use IntelliJ. Just guessing from the failure messages...

14:38 Anniepoo: yah, hoped it was something somebody had a formulaic answer for

14:38 going to try removing and reinstalling la clojure

14:38 Drakeson`: kotarak: is there a path I can put new-thing.clj after I started running a clojure instance, and then ask the running instance to require it?

14:39 kotarak: Drakeson`: You can add a directory to your classpath. Then start the JVM: java -cp my-dir:clojure.jar clojure.main -r. Copy a file to my-dir. "require" it.

14:40 The file has to follow the usual nameing conventions.

14:42 Drakeson`: kotarak: that's great. thanks a lot.

14:45 kotarak: Drakeson`: you are welcome

14:57 quidnunc: cgrand: Is it possible to use xml-zip functions on the results returned by enlive's select?

15:51 leafw: I am trying to compile clojure-contrib.jar with AOT, but it's not happening: I don't get the 1.7mb file but a .jar file of ~300 kb like the slim.jar one

15:51 what has changed? Having clojure.jar in the -Dclojure.jar=... is no enough?

15:53 also, how can one get clojure.jar itself to be compiled with AOT?

16:00 kotarak: leafw: AFAIK, clojure.jar is per default AOT compiled. The non-compiled one is clojure-slim.jar. "ant -Dclojure.jar=..." was enough to AOT compile contrib when I check the last time.

16:01 leafw: kotarak: thanks. But it's not compiling now -- clojure-contrib.jar, at least.

16:01 kotarak: Let me check here.

16:02 * kotarak is just going about doing an update.

16:03 hoeck: leafw: just compiled it here, what says your ant output?

16:05 leafw: now it compiles, after I compiled clojure.jar again (?)

16:05 2.6 mb clojure-contrib.jar, as expected

16:05 no idea what was happening here.

16:06 hiredman: my clojure-contrib.jar is around 4mb

16:06 leafw: by the way, my custom-build GUI clojure REPL stopped working after clojure svn revision 1352

16:06 kotarak: o.O

16:07 4mb! Mine is also around 2.5mb

16:07 leafw: hiredman: what JVM? Lots of inlining in 4m!

16:08 if anyone knows of a nice way to create a REPL with recent versions, please let me know. The old clojure.lang.Repl is basically deprecated, and currently devoid of any content. How does one use clojure.main for a Repl?

16:09 hiredman: 4.1M clojure-contrib.jar

16:10 kotarak: leafw: one call the repl function form clojure.main with lots of callbacks to configure everything. There is also a stream-repl somewhere.

16:10 hiredman: java -cp clojure.jar clojure.main will print out a nice help message

16:11 cp2: 450MHz P3 running F@H

16:12 im such a contributor

16:12 leafw: hiredman: no help message here. How do you make it show?

16:13 I am going to try to emulate clojure.main, simply.

16:13 hiredman: oh

16:13 huh, I thought it printed out the help message if called with no args

16:13 leafw: no, goes to repl directly.

16:14 hiredman: so there is a repl for you

16:14 kotarak: leafw: you lookup the docstring of clojure.main/repl or so.

16:14 you can ...

16:20 leafw: it's very frustrating. I had a working REPL in a GUI, and not anymore. I keep getting : REQUIRE.invoke(CLOJURE_MAIN)

16:21 sorry

16:21 java.lang.ExceptionInInitializerError

16:21 at clojure.lang.Namespace.<init>(Namespace.java:32)

16:21 at clojure.lang.Namespace.findOrCreate(Namespace.java:122)

16:21 at Clojure.Clojure_Interpreter.<clinit>(Clojure_Interpreter.java:47)

16:21 which basically means, touching the Namespace makes it fail.

16:21 kotarak: Look at the cause.

16:21 leafw: 4 concatenated causes

16:21 kotarak: It will tell you why there was in ExceptionInInitializerError.

16:22 leafw: yes kotarak , I know. The problem is: what does clojure need to start accepting commands/statements?

16:23 before, one just did a refer to the user namespace

16:23 now that is not accepted.

16:23 (Exception)

16:24 none of the 4 causes have anything to do with my application. They are all lost in the undocumented realm of what does clojure need to start up its machinery.

16:24 before, with the non-dummy clojure.lang.Repl class, it was clear.

16:25 now, with clojure.main, its no longer clear -- or what the main has it's not sufficient. Merely copying it fails.

16:32 needless to sya, very frustrating

16:32 s/sya/say/

16:32 kotarak: Hmm.. What happens if you call clojure.main/repl directly?

16:32 leafw: kotarak: no such method ... it's legacy_repl(...)

16:33 which is just final static private Var LEGACY_REPL = Var.intern(CLOJURE_MAIN_NS, Symbol.create("legacy-repl")) and then REQUIRE.invoke(CLOJURE_MAIN) and then LEGACY_REPL.invoke(RT.seq(args))

16:34 i.e. it creates symbols, it require them, and then it invokes them (?) as if that was supposed to do something. Are this magic tokens?

16:34 and I cannot do so, because it would start at REPL in stdout, which is not what I want.

16:35 I don't want to start a REPL. I have my own LineNumberingPushbackReader that reads from a TextArea after return.

16:36 kotarak: leafw: have a look in src/clj/clojure/main.clj for the repl function.

16:37 leafw: looking

16:37 kotarak: leafw: it let's specify read and write hooks and such

16:38 leafw: kotarak: I am reading the doc for repl-read. Sounds interesting

16:38 kotarak: leafw: a little further the docstring of repl should also be interesting for you.

16:39 leafw: on it atm

16:43 so essentially I have to define new thread-bound vars *in* and *out* and all should be fine

16:43 after invoking main fn.

16:44 up to know I was also manually managing *e, *1, *2, *3 and others

16:44 doesn't look like it'll do it for me, but at the same time it doens't return anything ... it's a bit onfusing.

16:48 so far I was using *out* only, and relying on LineNumberingPushbackReader lnpr = new LineNumberingPushbackReader(new StringReader(text)); and a Object r = LispReader.read(lnpr, false, EOF, false); to parse it.

16:49 I see no advantage to using clojure read fn

16:50 kotarak: leafw: read is maybe the more stable API

16:50 leafw: I would still have to set a new *in* everytime, and call invoke on the "repl-read" Var.

16:50 the problem is I don't understand at all what changed. Why it can't work now.

16:51 the Exceptions are totally not useful

16:57 failing at something as basic as : static final Var in_ns = RT.var("clojure.core", "in-ns"); I had created clojure-core before that as: static final Symbol CLOJURE = Symbol.create("clojure.core");

17:01 I think I am starting to understand the problem: the reader assumes there is a valid *in* anyway somewhere.

17:02 but I cannot set it via RT.var because RT.var itself is throwing that error.

17:06 it puzzles me beyond end that clojure.main can call, in its static private variables, RT.var(...), but I can't: throws an Exception.

17:13 elight: Hi all. Anyone know if there's been any movement toward getting Clojure running on Android?

17:14 I converted the Clojure JAR to Dalvik bytecodes but the blasted thing barfs when I try to run it in the emulator from shell.

17:14 kotarak: elight: There is.

17:14 elight: you could search the google group for threads.

17:14 elight: kotarak: I've done a bit of googling. Information seems sparse. Mostly that Rich has been considering it.

17:15 kotarak: elight: there was someone working on it. Maybe you can ask him directly.

17:15 elight: kotarak: Huh. K, thanks.

17:16 Just dying to have something other than vanilla Java to work in. Vanilla Java is hell....

17:17 kotarak: Hrmmm... git://github.com/remvee/clojure.git clojure-androi ?

17:17 kotarak: Hrmmm... git://github.com/remvee/clojure.git clojure-android ? (typo)

17:18 kotarak: elight: ? I don't know. Never used Android....

17:18 elight: kotarak: ah, ok

17:19 kotarak: elight: I would just contact the author of the threads in the group.

17:19 It seems he got relatively far..

17:19 leafw: kotarak, how does the nailgun server run clojure? That is conceptually similar--source code available?

17:21 kotarak: leafw: this is really a big hack. It "starts" a class. The class is generated via gen-class. In the class the whole environment is tugged away, because the connection are not contiguous. For each connect, the env is swapped in and stored away again after evaluating the request.

17:21 This happens in src/de/kotka/vimclojure/nails.clj in the Repl nail.

17:23 leafw: kotarak: ok.

17:23 kotarak: leafw: it basically uses *in* etc. provided by nailgun.

17:23 leafw: kotarak: I tried running clojure.main.main(new String[0]) and ... it fails. Fails! Can only be run from the command line

17:23 kotarak: That magic is in the defnail macro, IIRC

17:26 leafw: considering current state of things, until someone can explain conclusively ( rhickey ) why clojure.main.main(new String[0]); cannot be run from wnywhere lese except the command line, I go back a dozen commits. What a pain.

17:28 cgrand: quidnunc`: it depends -- you may need to change select*

17:37 lisppaste8: cgrand pasted "zip-select for quidnunc`" at http://paste.lisp.org/display/81467

17:40 Anniepoo: I had found some way of getting a popup of the doc string for lib function in La Clojure. Now I've lost track of it. Can someone please tell me what it is?

17:41 drewolson: hey all. i'm working on a clojure wrapper of the github api and had a question about the best way to test functions that will eventually make an http request

17:41 i'm an oo language, i'd usually just stub out the http call but i'm not sure how to approach this in clojure

17:41 *in an

17:43 hiredman: you factor out the actually http-request into the simplest function you can, then when testing, you just (binding [http-request-fn somedummy-fn] tests here)

17:44 drewolson: hiredman: awesome, that's exactly what i was looking for

17:44 will that binding affect all namespaces?

17:45 hiredman: hmmm

17:46 actually, there is the possibilty for a lot of complexity there, so I am note sure

17:46 I ahve used it in a few similar situations across namespaces

17:46 drewolson: right, that's what i was thinking... i have a namespace for user requests, which uses a method in a namespace called "foo" to make the http request

17:47 i'd like the function in foo to behave in a specific way for a given test. seems tricky.

17:51 hiredman: actually, that did seem to work

18:50 Anniepoo: I had found some way of getting a popup of the doc string for lib function in La Clojure. Now I've lost track of it. Can someone please tell me what it is?

18:51 tbatchelli1: I think it's Ctrl+J, but I believe it only works when looking up Java methods, but not for clojure vars

18:51 Anniepoo: hmm

18:52 tbatchelli1: the lookup of documentation on clojure variables and functions is not implemented yet, according to Ilya

18:52 Anniepoo: thanks

18:52 I must be confusing it with ctrl shift I for the java function lookup

20:21 chouser: ,Math/PI

20:21 clojurebot: 3.141592653589793

20:26 cp2: Cherry/PI

20:28 chouser: ,Cherry/PI

20:28 clojurebot: yummy!

Logging service provided by n01se.net